Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-07-02 11:43:29
Exec Total Coverage
Lines: 1750 4149 42.2%
Functions: 130 328 39.6%
Branches: 941 2694 34.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 #include <math.h>
18 #include <map>
19 #include <filesystem>
20 #include <ctype.h>
21 #include <sstream>
22 #include "base/zc_alleg.h"
23 #include "gamedata.h"
24 #include "zc/zc_init.h"
25 #include "init.h"
26 #include "zc/replay.h"
27 #include "zc/cheats.h"
28 #include "zc/render.h"
29 #include "base/zc_math.h"
30 #include "base/zapp.h"
31 #include "dialog/cheatkeys.h"
32 #include "metadata/metadata.h"
33 #include "zc/zelda.h"
34 #include "tiles.h"
35 #include "base/colors.h"
36 #include "pal.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 #include "zc/zc_sys.h"
40 #include "play_midi.h"
41 #include "jwin_a5.h"
42 #include "base/jwinfsel.h"
43 #include "base/gui.h"
44 #include "midi.h"
45 #include "subscr.h"
46 #include "zc/maps.h"
47 #include "sprite.h"
48 #include "zc/guys.h"
49 #include "zc/hero.h"
50 #include "zc/title.h"
51 #include "particles.h"
52 #include "zconsole.h"
53 #include "zc/ffscript.h"
54 #include "dialog/info.h"
55 #include "dialog/alert.h"
56 #include "zc/combos.h"
57 #include <fmt/format.h>
58
59 #ifdef __EMSCRIPTEN__
60 #include "base/emscripten_utils.h"
61 #endif
62
63 extern FFScript FFCore;
64 extern bool Playing;
65 int32_t sfx_voice[WAV_COUNT];
66 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
67 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
68
69 extern byte monochrome_console;
70
71 extern HeroClass Hero;
72 extern FFScript FFCore;
73 extern ZModule zcm;
74 extern zcmodule moduledata;
75 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
76 extern particle_list particles;
77 extern int32_t loadlast;
78 extern char *sfx_string[WAV_COUNT];
79 byte use_dwm_flush;
80 byte use_save_indicator;
81 byte midi_patch_fix;
82 bool midi_paused=false;
83 int32_t paused_midi_pos = 0;
84 byte midi_suspended = 0;
85 byte callback_switchin = 0;
86 byte zc_192b163_warp_compatibility;
87 char modulepath[2048];
88 bool epilepsyFlashReduction;
89 signed char pause_in_background_menu_init = 0;
90 byte pause_in_background = 0;
91 bool is_sys_pal = false;
92 static bool load_control_called_this_frame;
93 extern PALETTE* hw_palette;
94 extern bool update_hw_pal;
95 extern const char* dmaplist(int32_t index, int32_t* list_size);
96 int32_t getnumber(const char *prompt,int32_t initialval);
97
98 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
99 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
100 //extern byte refresh_select_screen;
101 //extern movingblock mblock2; //mblock[4]?
102 //extern int32_t db;
103
104 static const char *ZC_str = "Zelda Classic";
105 extern char save_file_name[1024];
106 #if defined(ALLEGRO_WINDOWS)
107 const char *qst_dir_name = "win_qst_dir";
108 static const char *qst_module_name = "current_module";
109 #elif defined(ALLEGRO_LINUX)
110 const char *qst_dir_name = "linux_qst_dir";
111 static const char *qst_module_name = "current_module";
112 #elif defined(__APPLE__)
113 const char *qst_dir_name = "osx_qst_dir";
114 static const char *qst_module_name = "current_module";
115 #endif
116 #ifdef ALLEGRO_LINUX
117 static const char *samplepath = "samplesoundset/patches.dat";
118 #endif
119 char qst_files_path[2048];
120
121 #ifdef _MSC_VER
122 #define getcwd _getcwd
123 #endif
124
125 bool rF11();
126 bool rI();
127 bool rQ();
128 bool zc_key_pressed();
129
130 #ifdef _WIN32
131
132 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
133 extern "C"
134 {
135 typedef HRESULT(WINAPI *t_DwmFlush)();
136 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
137 }
138
139 void do_DwmFlush()
140 {
141 static HMODULE shell = LoadLibrary("dwmapi.dll");
142
143 if(!shell)
144 return;
145
146 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
147 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
148
149 BOOL enabled;
150 isEnabled(&enabled);
151
152 if(isEnabled)
153 flush();
154 }
155
156 #endif // _WIN32
157
158 82835 bool flash_reduction_enabled(bool check_qr)
159 {
160
4/4
✓ Branch 0 taken 80614 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 80158 times.
✓ Branch 3 taken 82379 times.
82835 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
161 }
162
163 // Dialogue largening
164 void large_dialog(DIALOG *d)
165 {
166 large_dialog(d, 1.5);
167 }
168
169 void large_dialog(DIALOG *d, float RESIZE_AMT)
170 {
171 if(!d[0].d1)
172 {
173 d[0].d1 = 1;
174 int32_t oldwidth = d[0].w;
175 int32_t oldheight = d[0].h;
176 int32_t oldx = d[0].x;
177 int32_t oldy = d[0].y;
178 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
179 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
180 d[0].w = int32_t(d[0].w*RESIZE_AMT);
181 d[0].h = int32_t(d[0].h*RESIZE_AMT);
182
183 for(int32_t i=1; d[i].proc !=NULL; i++)
184 {
185 // Place elements horizontally
186 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
187 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
188
189 if(d[i].proc != d_stringloader)
190 {
191 if(d[i].proc==d_bitmap_proc)
192 {
193 d[i].w *= 2;
194 }
195 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
196 }
197
198 // Place elements vertically
199 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
200 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
201
202 // Vertically resize elements
203 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
204 {
205 d[i].h = int32_t((double)d[i].h*1.5);
206 }
207 else if(d[i].proc == jwin_droplist_proc)
208 {
209 d[i].y += int32_t((double)d[i].h*0.25);
210 d[i].h = int32_t((double)d[i].h*1.25);
211 }
212 else if(d[i].proc==d_bitmap_proc)
213 {
214 d[i].h *= 2;
215 }
216 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
217
218 // Fix frames
219 if(d[i].proc == jwin_frame_proc)
220 {
221 d[i].x++;
222 d[i].y++;
223 d[i].w-=4;
224 d[i].h-=4;
225 }
226 }
227 }
228
229 for(int32_t i=1; d[i].proc!=NULL; i++)
230 {
231 if(d[i].proc==jwin_slider_proc)
232 continue;
233
234 // Bigger font
235 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
236
237 if(!d[i].dp2 && bigfontproc)
238 {
239 d[i].dp2 = get_zc_font(font_lfont_l);
240 }
241 else if(!bigfontproc)
242 {
243 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
244 }
245
246 // Make checkboxes work
247 if(d[i].proc == jwin_check_proc)
248 d[i].proc = jwin_checkfont_proc;
249 else if(d[i].proc == jwin_radio_proc)
250 d[i].proc = jwin_radiofont_proc;
251 }
252
253 jwin_center_dialog(d);
254 }
255
256
257 /**********************************/
258 /******** System functions ********/
259 /**********************************/
260
261 static char cfg_sect[] = "zeldadx"; //We need to rename this.
262 static char ctrl_sect[] = "Controls";
263 static char sfx_sect[] = "Volume";
264
265 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
266 {
267 return D_O_K;
268 }
269
270 bool is_reserved_key(int c)
271 {
272 switch(c)
273 {
274 case KEY_ESC:
275 return true;
276 }
277 return false;
278 }
279 bool is_reserved_keycombo(int c, int modflag)
280 {
281 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
282 return true;
283 return false;
284 }
285 bool checkcheat(Cheat cheat)
286 {
287 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
288 return true; //Main key pressed
289 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
290 return true; //Alt key pressed
291 return false;
292 }
293 38 void load_default_cheatkeys()
294 {
295 38 memset(cheatkeys, 0, sizeof(cheatkeys));
296 38 cheatkeys[Cheat::Life][0] = KEY_H;
297 38 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
298 38 cheatkeys[Cheat::Magic][0] = KEY_M;
299 38 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
300 38 cheatkeys[Cheat::Rupies][0] = KEY_R;
301 38 cheatkeys[Cheat::Bombs][0] = KEY_B;
302 38 cheatkeys[Cheat::Arrows][0] = KEY_A;
303 38 cheatkeys[Cheat::Clock][0] = KEY_I;
304 38 cheatkeys[Cheat::Walls][0] = KEY_F11;
305 38 cheatkeys[Cheat::Fast][0] = KEY_Q;
306 38 cheatkeys[Cheat::Light][0] = KEY_L;
307 38 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
308 38 cheatkeys[Cheat::Kill][0] = KEY_K;
309 38 cheatkeys[Cheat::GoTo][0] = KEY_G;
310 38 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
311 38 cheatkeys[Cheat::ShowL0][0] = KEY_0;
312 38 cheatkeys[Cheat::ShowL1][0] = KEY_1;
313 38 cheatkeys[Cheat::ShowL2][0] = KEY_2;
314 38 cheatkeys[Cheat::ShowL3][0] = KEY_3;
315 38 cheatkeys[Cheat::ShowL4][0] = KEY_4;
316 38 cheatkeys[Cheat::ShowL5][0] = KEY_5;
317 38 cheatkeys[Cheat::ShowL6][0] = KEY_6;
318 38 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
319 38 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
320 38 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
321 38 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
322 38 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
323 38 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
324 38 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
325 38 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
326 38 }
327 38 void load_game_configs()
328 {
329 38 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
330 38 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
331 38 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
332 38 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
333 38 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
334 38 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
335 38 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
336 38 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
337 38 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
338 38 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
339 38 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
340 38 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
341 38 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
342 38 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
343 38 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
344
345 //cheat modifier keya
346 38 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
347 38 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
348 38 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
349 38 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
350
351 //cheat keys
352 38 load_default_cheatkeys();
353 char buf[256];
354
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 38 times.
1368 for(size_t q = 1; q < Cheat::Last; ++q)
355 {
356
1/2
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
1330 if(!bindable_cheat((Cheat)q)) continue;
357 1330 std::string cheatname = cheat_to_string((Cheat)q);
358
1/2
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
1330 util::lowerstr(cheatname);
359 1330 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
360
1/2
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
1330 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
361 1330 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
1330 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
363 1330 }
364
365
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
366 joystick_index = 0;
367
368 38 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
369 38 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
370 38 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
371 38 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
372 38 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
373 38 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
374 38 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
375 38 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
376 38 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
377 38 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
378
379 38 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
380 38 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
381 38 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
382 38 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
383
384 38 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
385 38 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
386 38 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
387 38 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
388 38 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
389 38 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
390 38 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
391 38 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
392 38 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
393 38 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
394 38 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
395
396 38 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
397 38 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
398 38 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
399 38 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
400
401 38 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
402
403 38 digi_volume = zc_get_config(sfx_sect,"digi",248);
404 38 midi_volume = zc_get_config(sfx_sect,"midi",255);
405 38 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
406 38 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
407 38 pan_style = zc_get_config(sfx_sect,"pan",1);
408 // 1 <= zcmusic_bufsz <= 128
409 38 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
410 38 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
411 38 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
412 38 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
413 38 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
414 38 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
415 38 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
416 #ifdef __EMSCRIPTEN__
417 if (em_is_mobile()) NameEntryMode = 2;
418 #endif
419 38 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
420 38 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
421 38 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
422 38 title_version = zc_get_config(cfg_sect,"title",2);
423 38 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
424 38 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
425
426 //default - scale x2, 640 x 480
427 38 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
428 38 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
429 38 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
430 38 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
431 38 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
432 38 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
433 38 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
434
435 38 loadlast = zc_get_config(cfg_sect,"load_last",0);
436
437 38 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
438
439 38 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
440
441 38 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
442 38 info_opacity = zc_get_config("zc","debug_info_opacity",255);
443 #ifdef _WIN32
444 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
445 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
446 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
447 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
448
449 // This one's for Aero
450 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
451
452 // And this one fixes patches unloading on some MIDI setups
453 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
454 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
455 #else //UNIX
456 38 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
457 38 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
458 38 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
459 #endif
460 38 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
461 38 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
462
463 38 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
464
465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(strlen(qstdir)==0)
466 {
467 38 getcwd(qstdir,2048);
468 38 fix_filename_case(qstdir);
469 38 fix_filename_slashes(qstdir);
470 38 put_backslash(qstdir);
471 38 }
472 else
473 {
474 chop_path(qstdir);
475 }
476
477 38 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
478 38 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
479 38 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
480 38 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
481 38 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
482 38 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
483 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
484 38 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
485 38 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
486 38 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
487 38 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
488 38 }
489
490 void save_control_configs(bool kb)
491 {
492 if(kb)
493 {
494 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
495 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
496 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
497 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
498
499 if (!replay_is_replaying())
500 {
501 zc_set_config(ctrl_sect,"key_a",Akey);
502 zc_set_config(ctrl_sect,"key_b",Bkey);
503 zc_set_config(ctrl_sect,"key_s",Skey);
504 zc_set_config(ctrl_sect,"key_l",Lkey);
505 zc_set_config(ctrl_sect,"key_r",Rkey);
506 zc_set_config(ctrl_sect,"key_p",Pkey);
507 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
508 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
509 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
510 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
511 zc_set_config(ctrl_sect,"key_up", DUkey);
512 zc_set_config(ctrl_sect,"key_down", DDkey);
513 zc_set_config(ctrl_sect,"key_left", DLkey);
514 zc_set_config(ctrl_sect,"key_right",DRkey);
515 }
516 }
517 else
518 {
519 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
520 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
521 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
522 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
523 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
524 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
525 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
526 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
527 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
528 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
529 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
530 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
531 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
532 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
533
534 zc_set_config(ctrl_sect,"btn_a",Abtn);
535 zc_set_config(ctrl_sect,"btn_b",Bbtn);
536 zc_set_config(ctrl_sect,"btn_s",Sbtn);
537 zc_set_config(ctrl_sect,"btn_m",Mbtn);
538 zc_set_config(ctrl_sect,"btn_l",Lbtn);
539 zc_set_config(ctrl_sect,"btn_r",Rbtn);
540 zc_set_config(ctrl_sect,"btn_p",Pbtn);
541 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
542 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
543 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
544 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
545
546 zc_set_config(ctrl_sect,"btn_up",DUbtn);
547 zc_set_config(ctrl_sect,"btn_down",DDbtn);
548 zc_set_config(ctrl_sect,"btn_left",DLbtn);
549 zc_set_config(ctrl_sect,"btn_right",DRbtn);
550 }
551 }
552
553 void save_cheatkeys()
554 {
555 char buf[256];
556 for(size_t q = 1; q < Cheat::Last; ++q)
557 {
558 if(!bindable_cheat((Cheat)q)) continue;
559 std::string cheatname = cheat_to_string((Cheat)q);
560 util::lowerstr(cheatname);
561 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
562 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
563 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
564 if(cheatkeys[q][1])
565 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
566 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
567 }
568 }
569
570 void save_game_configs()
571 {
572 packfile_password("");
573
574 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
575
576 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
577 {
578 int o_window_x, o_window_y;
579 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
580 zc_set_config(cfg_sect,"window_x",o_window_x);
581 zc_set_config(cfg_sect,"window_y",o_window_y);
582 }
583
584 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
585 {
586 double monitor_scale = zc_get_monitor_scale();
587 window_width = al_get_display_width(all_get_display()) / monitor_scale;
588 window_height = al_get_display_height(all_get_display()) / monitor_scale;
589 zc_set_config(cfg_sect,"window_width",window_width);
590 zc_set_config(cfg_sect,"window_height",window_height);
591 }
592
593 zc_set_config(cfg_sect,"load_last",loadlast);
594 chop_path(qstdir);
595 zc_set_config(cfg_sect,qst_dir_name,qstdir);
596 zc_set_config("SAVEFILE","save_filename",save_file_name);
597 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
598
599 flush_config_file();
600 #ifdef __EMSCRIPTEN__
601 em_sync_fs();
602 #endif
603 }
604
605 //----------------------------------------------------------------
606
607 // Timers
608
609 33404 void fps_callback()
610 {
611 33404 lastfps=framecnt;
612 33404 dword tempsecs = fps_secs;
613 33404 ++tempsecs;
614 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
615 33404 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
616 33404 ++fps_secs;
617 33404 framecnt=0;
618 33404 }
619
620 END_OF_FUNCTION(fps_callback)
621
622 38 int32_t Z_init_timers()
623 {
624 static bool didit = false;
625 const static char *err_str = "Couldn't allocate timer";
626 38 err_str = err_str; //Unused variable warning
627
628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(didit)
629 return 1;
630
631 38 didit = true;
632
633 LOCK_VARIABLE(lastfps);
634 LOCK_VARIABLE(framecnt);
635 LOCK_FUNCTION(fps_callback);
636
637
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
638 return 0;
639
640 38 return 1;
641 38 }
642
643 void Z_remove_timers()
644 {
645 remove_int(fps_callback);
646 }
647
648 //----------------------------------------------------------------
649
650 void go()
651 {
652 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
653 }
654
655 void comeback()
656 {
657 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
658 }
659
660 void dump_pal(BITMAP *dest)
661 {
662 for(int32_t i=0; i<256; i++)
663 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
664 }
665
666 //----------------------------------------------------------------
667
668 int game_mouse_index = ZCM_BLANK;
669 static bool system_mouse = false;
670 102 bool sys_mouse()
671 {
672 102 system_mouse = true;
673 102 return MouseSprite::set(ZCM_NORMAL);
674 }
675 469 bool game_mouse()
676 {
677 469 system_mouse = false;
678 469 return MouseSprite::set(game_mouse_index);
679 }
680 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
681 {
682 if(!bmp)
683 return;
684 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
685 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
686 if(bmp->w == scaledw && bmp->h == scaledh)
687 user_scale = false;
688 if(user_scale || sys_recolor)
689 {
690 if(!user_scale) scale = 1;
691 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
692 if(user_scale)
693 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
694 else
695 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
696 if(sys_recolor)
697 recolor_mouse(tmpbmp);
698 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
699 destroy_bitmap(tmpbmp);
700 }
701 else
702 {
703 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
704 }
705 }
706
707 //Handles converting the mouse sprite from the .dat file
708 38 void recolor_mouse(BITMAP* bmp)
709 {
710
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 38 times.
646 for(int32_t x = 0; x < bmp->w; ++x)
711 {
712
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 608 times.
10336 for(int32_t y = 0; y < bmp->h; ++y)
713 {
714 9728 int32_t color = getpixel(bmp, x, y);
715
5/5
✓ Branch 0 taken 6612 times.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 836 times.
✓ Branch 3 taken 874 times.
✓ Branch 4 taken 684 times.
9728 switch(color)
716 {
717 case dvc(1):
718 722 color = jwin_pal[jcCURSORMISC];
719 722 break;
720 case dvc(2):
721 836 color = jwin_pal[jcCURSOROUTLINE];
722 836 break;
723 case dvc(3):
724 874 color = jwin_pal[jcCURSORLIGHT];
725 874 break;
726 case dvc(5):
727 684 color = jwin_pal[jcCURSORDARK];
728 684 break;
729 default:
730 6612 continue;
731 }
732 3116 putpixel(bmp, x, y, color);
733 3116 }
734 608 }
735 38 }
736 38 void load_mouse()
737 {
738 38 enter_sys_pal();
739 38 MouseSprite::set(-1);
740 38 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
741 38 int32_t sz = 16*scale;
742
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 38 times.
76 for(int32_t j = 0; j < 1; ++j)
743 {
744 38 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
745
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(zcmouse[j])
746 destroy_bitmap(zcmouse[j]);
747 38 zcmouse[j] = create_bitmap_ex(8,sz,sz);
748 38 clear_bitmap(zcmouse[j]);
749 38 clear_bitmap(tmpbmp);
750 38 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
751 38 recolor_mouse(tmpbmp);
752
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(sz!=16)
753 38 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
754 else
755 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
756 38 destroy_bitmap(tmpbmp);
757 38 }
758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(!hw_palette) hw_palette = &RAMpal;
759 38 zc_set_palette(*hw_palette);
760
761 38 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
762 38 clear_bitmap(blankmouse);
763
764 38 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
765 38 MouseSprite::assign(ZCM_BLANK, blankmouse);
766 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
767
768 //Reload the mouse
769
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(system_mouse)
770 38 sys_mouse();
771 else game_mouse();
772
773 38 destroy_bitmap(blankmouse);
774 38 exit_sys_pal();
775 38 }
776
777 // sets the video mode and initializes the palette and mouse sprite
778 38 bool game_vid_mode(int32_t mode,int32_t wait)
779 {
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
781 {
782 return false;
783 }
784
785 38 scrx = (resx-320)>>1;
786 38 scry = (resy-240)>>1;
787
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 38 times.
76 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
788 38 zcmouse[q] = NULL;
789 38 load_mouse();
790
791
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 38 times.
646 for(int32_t i=240; i<256; i++)
792 608 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
793
794 38 zc_set_palette(RAMpal);
795 38 clear_to_color(screen,BLACK);
796
797 38 rest(wait);
798 38 return true;
799 38 }
800
801 8 void null_quest()
802 {
803 char qstdat_string[2048];
804 8 strcpy(qstdat_string, "modules/classic/default.qst");
805
806 #ifdef __EMSCRIPTEN__
807 // The quest template data file is not included because it's really big and isn't really needed
808 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
809 // which is much smaller.
810 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
811 #endif
812
813 8 byte skip_flags[4] = { 0 };
814
815 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,skip_flags,0,false);
816 8 }
817
818 // TODO remove
819 8 void init_NES_mode()
820 {
821 8 null_quest();
822 8 }
823
824 //----------------------------------------------------------------
825
826 qword trianglelines[16]=
827 {
828 0x0000000000000000ULL,
829 0xFD00000000000000ULL,
830 0xFDFD000000000000ULL,
831 0xFDFDFD0000000000ULL,
832 0xFDFDFDFD00000000ULL,
833 0xFDFDFDFDFD000000ULL,
834 0xFDFDFDFDFDFD0000ULL,
835 0xFDFDFDFDFDFDFD00ULL,
836 0xFDFDFDFDFDFDFDFDULL,
837 0x00FDFDFDFDFDFDFDULL,
838 0x0000FDFDFDFDFDFDULL,
839 0x000000FDFDFDFDFDULL,
840 0x00000000FDFDFDFDULL,
841 0x0000000000FDFDFDULL,
842 0x000000000000FDFDULL,
843 0x00000000000000FDULL,
844 };
845
846 word screen_triangles[28][32];
847 /*
848 qword triangles[4][16]= //[direction][value]
849 {
850 {
851 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
852 },
853 {
854 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
855 },
856 {
857 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
858 },
859 {
860 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
861 }
862 };
863 */
864
865
866 /*
867 byte triangles[4][16][8]= //[direction][value][line]
868 {
869 {
870 {
871 0, 0, 0, 0, 0, 0, 0, 0
872 },
873 {
874 1, 0, 0, 0, 0, 0, 0, 0
875 },
876 {
877 2, 1, 0, 0, 0, 0, 0, 0
878 },
879 {
880 3, 2, 1, 0, 0, 0, 0, 0
881 },
882 {
883 4, 3, 2, 1, 0, 0, 0, 0
884 },
885 {
886 5, 4, 3, 2, 1, 0, 0, 0
887 },
888 {
889 6, 5, 4, 3, 2, 1, 0, 0
890 },
891 {
892 7, 6, 5, 4, 3, 2, 1, 0
893 },
894 {
895 8, 7, 6, 5, 4, 3, 2, 1
896 },
897 {
898 8, 8, 7, 6, 5, 4, 3, 2
899 },
900 {
901 8, 8, 8, 7, 6, 5, 4, 3
902 },
903 {
904 8, 8, 8, 8, 7, 6, 5, 4
905 },
906 {
907 8, 8, 8, 8, 8, 7, 6, 5
908 },
909 {
910 8, 8, 8, 8, 8, 8, 7, 6
911 },
912 {
913 8, 8, 8, 8, 8, 8, 8, 7
914 },
915 {
916 8, 8, 8, 8, 8, 8, 8, 8
917 }
918 },
919 {
920 {
921 0, 0, 0, 0, 0, 0, 0, 0
922 },
923 {
924 15, 0, 0, 0, 0, 0, 0, 0
925 },
926 {
927 14, 15, 0, 0, 0, 0, 0, 0
928 },
929 {
930 13, 14, 15, 0, 0, 0, 0, 0
931 },
932 {
933 12, 13, 14, 15, 0, 0, 0, 0
934 },
935 {
936 11, 12, 13, 14, 15, 0, 0, 0
937 },
938 {
939 10, 11, 12, 13, 14, 15, 0, 0
940 },
941 {
942 9, 10, 11, 12, 13, 14, 15, 0
943 },
944 {
945 8, 9, 10, 11, 12, 13, 14, 15
946 },
947 {
948 8, 8, 9, 10, 11, 12, 13, 14
949 },
950 {
951 8, 8, 8, 9, 10, 11, 12, 13
952 },
953 {
954 8, 8, 8, 8, 9, 10, 11, 12
955 },
956 {
957 8, 8, 8, 8, 8, 9, 10, 11
958 },
959 {
960 8, 8, 8, 8, 8, 8, 9, 10
961 },
962 {
963 8, 8, 8, 8, 8, 8, 8, 9
964 },
965 {
966 8, 8, 8, 8, 8, 8, 8, 8
967 }
968 },
969 {
970 {
971 0, 0, 0, 0, 0, 0, 0, 0
972 },
973 {
974 0, 0, 0, 0, 0, 0, 0, 1
975 },
976 {
977 0, 0, 0, 0, 0, 0, 1, 2
978 },
979 {
980 0, 0, 0, 0, 0, 1, 2, 3
981 },
982 {
983 0, 0, 0, 0, 1, 2, 3, 4
984 },
985 {
986 0, 0, 0, 1, 2, 3, 4, 5
987 },
988 {
989 0, 0, 1, 2, 3, 4, 5, 6
990 },
991 {
992 0, 1, 2, 3, 4, 5, 6, 7
993 },
994 {
995 1, 2, 3, 4, 5, 6, 7, 8
996 },
997 {
998 2, 3, 4, 5, 6, 7, 8, 8
999 },
1000 {
1001 3, 4, 5, 6, 7, 8, 8, 8
1002 },
1003 {
1004 4, 5, 6, 7, 8, 8, 8, 8
1005 },
1006 {
1007 5, 6, 7, 8, 8, 8, 8, 8
1008 },
1009 {
1010 6, 7, 8, 8, 8, 8, 8, 8
1011 },
1012 {
1013 7, 8, 8, 8, 8, 8, 8, 8
1014 },
1015 {
1016 8, 8, 8, 8, 8, 8, 8, 8
1017 }
1018 },
1019 {
1020 {
1021 0, 0, 0, 0, 0, 0, 0, 0
1022 },
1023 {
1024 0, 0, 0, 0, 0, 0, 0, 15
1025 },
1026 {
1027 0, 0, 0, 0, 0, 0, 15, 14
1028 },
1029 {
1030 0, 0, 0, 0, 0, 15, 14, 13
1031 },
1032 {
1033 0, 0, 0, 0, 15, 14, 13, 12
1034 },
1035 {
1036 0, 0, 0, 15, 14, 13, 12, 11
1037 },
1038 {
1039 0, 0, 15, 14, 13, 12, 11, 10
1040 },
1041 {
1042 0, 15, 14, 13, 12, 11, 10, 9
1043 },
1044 {
1045 15, 14, 13, 12, 11, 10, 9, 8
1046 },
1047 {
1048 14, 13, 12, 11, 10, 9, 8, 8
1049 },
1050 {
1051 13, 12, 11, 10, 9, 8, 8, 8
1052 },
1053 {
1054 12, 11, 10, 9, 8, 8, 8, 8
1055 },
1056 {
1057 11, 10, 9, 8, 8, 8, 8, 8
1058 },
1059 {
1060 10, 9, 8, 8, 8, 8, 8, 8
1061 },
1062 {
1063 9, 8, 8, 8, 8, 8, 8, 8
1064 },
1065 {
1066 8, 8, 8, 8, 8, 8, 8, 8
1067 }
1068 }
1069 };
1070 */
1071
1072
1073
1074 /*
1075 for (int32_t blockrow=0; blockrow<30; ++i)
1076 {
1077 for (int32_t linerow=0; linerow<8; ++i)
1078 {
1079 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1080 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1081 {
1082 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1083 ++triangleline;
1084 }
1085 }
1086 }
1087 */
1088
1089 // the ULL suffixes are to prevent this warning:
1090 // warning: integer constant is too large for "int32_t" type
1091
1092 qword triangles[4][16][8]= //[direction][value][line]
1093 {
1094 {
1095 {
1096 0x0000000000000000ULL,
1097 0x0000000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL
1104 },
1105 {
1106 0xFD00000000000000ULL,
1107 0x0000000000000000ULL,
1108 0x0000000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL
1114 },
1115 {
1116 0xFDFD000000000000ULL,
1117 0xFD00000000000000ULL,
1118 0x0000000000000000ULL,
1119 0x0000000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL
1124 },
1125 {
1126 0xFDFDFD0000000000ULL,
1127 0xFDFD000000000000ULL,
1128 0xFD00000000000000ULL,
1129 0x0000000000000000ULL,
1130 0x0000000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL
1134 },
1135 {
1136 0xFDFDFDFD00000000ULL,
1137 0xFDFDFD0000000000ULL,
1138 0xFDFD000000000000ULL,
1139 0xFD00000000000000ULL,
1140 0x0000000000000000ULL,
1141 0x0000000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL
1144 },
1145 {
1146 0xFDFDFDFDFD000000ULL,
1147 0xFDFDFDFD00000000ULL,
1148 0xFDFDFD0000000000ULL,
1149 0xFDFD000000000000ULL,
1150 0xFD00000000000000ULL,
1151 0x0000000000000000ULL,
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL
1154 },
1155 {
1156 0xFDFDFDFDFDFD0000ULL,
1157 0xFDFDFDFDFD000000ULL,
1158 0xFDFDFDFD00000000ULL,
1159 0xFDFDFD0000000000ULL,
1160 0xFDFD000000000000ULL,
1161 0xFD00000000000000ULL,
1162 0x0000000000000000ULL,
1163 0x0000000000000000ULL
1164 },
1165 {
1166 0xFDFDFDFDFDFDFD00ULL,
1167 0xFDFDFDFDFDFD0000ULL,
1168 0xFDFDFDFDFD000000ULL,
1169 0xFDFDFDFD00000000ULL,
1170 0xFDFDFD0000000000ULL,
1171 0xFDFD000000000000ULL,
1172 0xFD00000000000000ULL,
1173 0x0000000000000000ULL
1174 },
1175 {
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFD00ULL,
1178 0xFDFDFDFDFDFD0000ULL,
1179 0xFDFDFDFDFD000000ULL,
1180 0xFDFDFDFD00000000ULL,
1181 0xFDFDFD0000000000ULL,
1182 0xFDFD000000000000ULL,
1183 0xFD00000000000000ULL
1184 },
1185 {
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFD00ULL,
1189 0xFDFDFDFDFDFD0000ULL,
1190 0xFDFDFDFDFD000000ULL,
1191 0xFDFDFDFD00000000ULL,
1192 0xFDFDFD0000000000ULL,
1193 0xFDFD000000000000ULL
1194 },
1195 {
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFD00ULL,
1200 0xFDFDFDFDFDFD0000ULL,
1201 0xFDFDFDFDFD000000ULL,
1202 0xFDFDFDFD00000000ULL,
1203 0xFDFDFD0000000000ULL
1204 },
1205 {
1206 0xFDFDFDFDFDFDFDFDULL,
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFD00ULL,
1211 0xFDFDFDFDFDFD0000ULL,
1212 0xFDFDFDFDFD000000ULL,
1213 0xFDFDFDFD00000000ULL
1214 },
1215 {
1216 0xFDFDFDFDFDFDFDFDULL,
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFD00ULL,
1222 0xFDFDFDFDFDFD0000ULL,
1223 0xFDFDFDFDFD000000ULL
1224 },
1225 {
1226 0xFDFDFDFDFDFDFDFDULL,
1227 0xFDFDFDFDFDFDFDFDULL,
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFD00ULL,
1233 0xFDFDFDFDFDFD0000ULL
1234 },
1235 {
1236 0xFDFDFDFDFDFDFDFDULL,
1237 0xFDFDFDFDFDFDFDFDULL,
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFD00ULL
1244 },
1245 {
1246 0xFDFDFDFDFDFDFDFDULL,
1247 0xFDFDFDFDFDFDFDFDULL,
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL
1254 }
1255 },
1256 {
1257 {
1258 0x0000000000000000ULL,
1259 0x0000000000000000ULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL
1266 },
1267 {
1268 0x00000000000000FDULL,
1269 0x0000000000000000ULL,
1270 0x0000000000000000ULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL
1276 },
1277 {
1278 0x000000000000FDFDULL,
1279 0x00000000000000FDULL,
1280 0x0000000000000000ULL,
1281 0x0000000000000000ULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL
1286 },
1287 {
1288 0x0000000000FDFDFDULL,
1289 0x000000000000FDFDULL,
1290 0x00000000000000FDULL,
1291 0x0000000000000000ULL,
1292 0x0000000000000000ULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL
1296 },
1297 {
1298 0x00000000FDFDFDFDULL,
1299 0x0000000000FDFDFDULL,
1300 0x000000000000FDFDULL,
1301 0x00000000000000FDULL,
1302 0x0000000000000000ULL,
1303 0x0000000000000000ULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL
1306 },
1307 {
1308 0x000000FDFDFDFDFDULL,
1309 0x00000000FDFDFDFDULL,
1310 0x0000000000FDFDFDULL,
1311 0x000000000000FDFDULL,
1312 0x00000000000000FDULL,
1313 0x0000000000000000ULL,
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL
1316 },
1317 {
1318 0x0000FDFDFDFDFDFDULL,
1319 0x000000FDFDFDFDFDULL,
1320 0x00000000FDFDFDFDULL,
1321 0x0000000000FDFDFDULL,
1322 0x000000000000FDFDULL,
1323 0x00000000000000FDULL,
1324 0x0000000000000000ULL,
1325 0x0000000000000000ULL
1326 },
1327 {
1328 0x00FDFDFDFDFDFDFDULL,
1329 0x0000FDFDFDFDFDFDULL,
1330 0x000000FDFDFDFDFDULL,
1331 0x00000000FDFDFDFDULL,
1332 0x0000000000FDFDFDULL,
1333 0x000000000000FDFDULL,
1334 0x00000000000000FDULL,
1335 0x0000000000000000ULL
1336 },
1337 {
1338 0xFDFDFDFDFDFDFDFDULL,
1339 0x00FDFDFDFDFDFDFDULL,
1340 0x0000FDFDFDFDFDFDULL,
1341 0x000000FDFDFDFDFDULL,
1342 0x00000000FDFDFDFDULL,
1343 0x0000000000FDFDFDULL,
1344 0x000000000000FDFDULL,
1345 0x00000000000000FDULL
1346 },
1347 {
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0x00FDFDFDFDFDFDFDULL,
1351 0x0000FDFDFDFDFDFDULL,
1352 0x000000FDFDFDFDFDULL,
1353 0x00000000FDFDFDFDULL,
1354 0x0000000000FDFDFDULL,
1355 0x000000000000FDFDULL
1356 },
1357 {
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0x00FDFDFDFDFDFDFDULL,
1362 0x0000FDFDFDFDFDFDULL,
1363 0x000000FDFDFDFDFDULL,
1364 0x00000000FDFDFDFDULL,
1365 0x0000000000FDFDFDULL
1366 },
1367 {
1368 0xFDFDFDFDFDFDFDFDULL,
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0x00FDFDFDFDFDFDFDULL,
1373 0x0000FDFDFDFDFDFDULL,
1374 0x000000FDFDFDFDFDULL,
1375 0x00000000FDFDFDFDULL
1376 },
1377 {
1378 0xFDFDFDFDFDFDFDFDULL,
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0x00FDFDFDFDFDFDFDULL,
1384 0x0000FDFDFDFDFDFDULL,
1385 0x000000FDFDFDFDFDULL
1386 },
1387 {
1388 0xFDFDFDFDFDFDFDFDULL,
1389 0xFDFDFDFDFDFDFDFDULL,
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0x00FDFDFDFDFDFDFDULL,
1395 0x0000FDFDFDFDFDFDULL
1396 },
1397 {
1398 0xFDFDFDFDFDFDFDFDULL,
1399 0xFDFDFDFDFDFDFDFDULL,
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0x00FDFDFDFDFDFDFDULL
1406 },
1407 {
1408 0xFDFDFDFDFDFDFDFDULL,
1409 0xFDFDFDFDFDFDFDFDULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL
1416 }
1417 },
1418 {
1419 {
1420 0x0000000000000000ULL,
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL
1428 },
1429 {
1430 0x0000000000000000ULL,
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0xFD00000000000000ULL
1438 },
1439 {
1440 0x0000000000000000ULL,
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0xFD00000000000000ULL,
1447 0xFDFD000000000000ULL
1448 },
1449 {
1450 0x0000000000000000ULL,
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0xFD00000000000000ULL,
1456 0xFDFD000000000000ULL,
1457 0xFDFDFD0000000000ULL
1458 },
1459 {
1460 0x0000000000000000ULL,
1461 0x0000000000000000ULL,
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0xFD00000000000000ULL,
1465 0xFDFD000000000000ULL,
1466 0xFDFDFD0000000000ULL,
1467 0xFDFDFDFD00000000ULL
1468 },
1469 {
1470 0x0000000000000000ULL,
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0xFD00000000000000ULL,
1474 0xFDFD000000000000ULL,
1475 0xFDFDFD0000000000ULL,
1476 0xFDFDFDFD00000000ULL,
1477 0xFDFDFDFDFD000000ULL
1478 },
1479 {
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0xFD00000000000000ULL,
1483 0xFDFD000000000000ULL,
1484 0xFDFDFD0000000000ULL,
1485 0xFDFDFDFD00000000ULL,
1486 0xFDFDFDFDFD000000ULL,
1487 0xFDFDFDFDFDFD0000ULL
1488 },
1489 {
1490 0x0000000000000000ULL,
1491 0xFD00000000000000ULL,
1492 0xFDFD000000000000ULL,
1493 0xFDFDFD0000000000ULL,
1494 0xFDFDFDFD00000000ULL,
1495 0xFDFDFDFDFD000000ULL,
1496 0xFDFDFDFDFDFD0000ULL,
1497 0xFDFDFDFDFDFDFD00ULL
1498 },
1499 {
1500 0xFD00000000000000ULL,
1501 0xFDFD000000000000ULL,
1502 0xFDFDFD0000000000ULL,
1503 0xFDFDFDFD00000000ULL,
1504 0xFDFDFDFDFD000000ULL,
1505 0xFDFDFDFDFDFD0000ULL,
1506 0xFDFDFDFDFDFDFD00ULL,
1507 0xFDFDFDFDFDFDFDFDULL
1508 },
1509 {
1510 0xFDFD000000000000ULL,
1511 0xFDFDFD0000000000ULL,
1512 0xFDFDFDFD00000000ULL,
1513 0xFDFDFDFDFD000000ULL,
1514 0xFDFDFDFDFDFD0000ULL,
1515 0xFDFDFDFDFDFDFD00ULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL
1518 },
1519 {
1520 0xFDFDFD0000000000ULL,
1521 0xFDFDFDFD00000000ULL,
1522 0xFDFDFDFDFD000000ULL,
1523 0xFDFDFDFDFDFD0000ULL,
1524 0xFDFDFDFDFDFDFD00ULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL
1528 },
1529 {
1530 0xFDFDFDFD00000000ULL,
1531 0xFDFDFDFDFD000000ULL,
1532 0xFDFDFDFDFDFD0000ULL,
1533 0xFDFDFDFDFDFDFD00ULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL
1538 },
1539 {
1540 0xFDFDFDFDFD000000ULL,
1541 0xFDFDFDFDFDFD0000ULL,
1542 0xFDFDFDFDFDFDFD00ULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL
1548 },
1549 {
1550 0xFDFDFDFDFDFD0000ULL,
1551 0xFDFDFDFDFDFDFD00ULL,
1552 0xFDFDFDFDFDFDFDFDULL,
1553 0xFDFDFDFDFDFDFDFDULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL
1558 },
1559 {
1560 0xFDFDFDFDFDFDFD00ULL,
1561 0xFDFDFDFDFDFDFDFDULL,
1562 0xFDFDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL
1568 },
1569 {
1570 0xFDFDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL
1578 }
1579 },
1580 {
1581 {
1582 0x0000000000000000ULL,
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL
1590 },
1591 {
1592 0x0000000000000000ULL,
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x00000000000000FDULL
1600 },
1601 {
1602 0x0000000000000000ULL,
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x00000000000000FDULL,
1609 0x000000000000FDFDULL
1610 },
1611 {
1612 0x0000000000000000ULL,
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x00000000000000FDULL,
1618 0x000000000000FDFDULL,
1619 0x0000000000FDFDFDULL
1620 },
1621 {
1622 0x0000000000000000ULL,
1623 0x0000000000000000ULL,
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x00000000000000FDULL,
1627 0x000000000000FDFDULL,
1628 0x0000000000FDFDFDULL,
1629 0x00000000FDFDFDFDULL
1630 },
1631 {
1632 0x0000000000000000ULL,
1633 0x0000000000000000ULL,
1634 0x0000000000000000ULL,
1635 0x00000000000000FDULL,
1636 0x000000000000FDFDULL,
1637 0x0000000000FDFDFDULL,
1638 0x00000000FDFDFDFDULL,
1639 0x000000FDFDFDFDFDULL
1640 },
1641 {
1642 0x0000000000000000ULL,
1643 0x0000000000000000ULL,
1644 0x00000000000000FDULL,
1645 0x000000000000FDFDULL,
1646 0x0000000000FDFDFDULL,
1647 0x00000000FDFDFDFDULL,
1648 0x000000FDFDFDFDFDULL,
1649 0x0000FDFDFDFDFDFDULL
1650 },
1651 {
1652 0x0000000000000000ULL,
1653 0x00000000000000FDULL,
1654 0x000000000000FDFDULL,
1655 0x0000000000FDFDFDULL,
1656 0x00000000FDFDFDFDULL,
1657 0x000000FDFDFDFDFDULL,
1658 0x0000FDFDFDFDFDFDULL,
1659 0x00FDFDFDFDFDFDFDULL
1660 },
1661 {
1662 0x00000000000000FDULL,
1663 0x000000000000FDFDULL,
1664 0x0000000000FDFDFDULL,
1665 0x00000000FDFDFDFDULL,
1666 0x000000FDFDFDFDFDULL,
1667 0x0000FDFDFDFDFDFDULL,
1668 0x00FDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL
1670 },
1671 {
1672 0x000000000000FDFDULL,
1673 0x0000000000FDFDFDULL,
1674 0x00000000FDFDFDFDULL,
1675 0x000000FDFDFDFDFDULL,
1676 0x0000FDFDFDFDFDFDULL,
1677 0x00FDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL
1680 },
1681 {
1682 0x0000000000FDFDFDULL,
1683 0x00000000FDFDFDFDULL,
1684 0x000000FDFDFDFDFDULL,
1685 0x0000FDFDFDFDFDFDULL,
1686 0x00FDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL
1690 },
1691 {
1692 0x00000000FDFDFDFDULL,
1693 0x000000FDFDFDFDFDULL,
1694 0x0000FDFDFDFDFDFDULL,
1695 0x00FDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL
1700 },
1701 {
1702 0x000000FDFDFDFDFDULL,
1703 0x0000FDFDFDFDFDFDULL,
1704 0x00FDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL
1710 },
1711 {
1712 0x0000FDFDFDFDFDFDULL,
1713 0x00FDFDFDFDFDFDFDULL,
1714 0xFDFDFDFDFDFDFDFDULL,
1715 0xFDFDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL
1720 },
1721 {
1722 0x00FDFDFDFDFDFDFDULL,
1723 0xFDFDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL
1730 },
1731 {
1732 0xFDFDFDFDFDFDFDFDULL,
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL
1740 }
1741 }
1742 };
1743
1744 int32_t black_opening_count=0;
1745 int32_t black_opening_x,black_opening_y;
1746 int32_t black_opening_shape;
1747
1748 1135 int32_t choose_opening_shape()
1749 {
1750 // First, count how many bits are set
1751 1135 int32_t numBits=0;
1752 int32_t bitCounter;
1753
1754
2/2
✓ Branch 0 taken 5675 times.
✓ Branch 1 taken 1135 times.
6810 for(int32_t i=0; i<bosMAX; i++)
1755 {
1756
2/2
✓ Branch 0 taken 4324 times.
✓ Branch 1 taken 1351 times.
5675 if(COOLSCROLL&(1<<i))
1757 1351 numBits++;
1758 5675 }
1759
1760 // Shouldn't happen...
1761
1/2
✓ Branch 0 taken 1135 times.
✗ Branch 1 not taken.
1135 if(numBits==0)
1762 return bosCIRCLE;
1763
1764 // Pick a bit
1765 1135 bitCounter=zc_rand()%numBits+1;
1766
1767
2/2
✓ Branch 0 taken 1401 times.
✓ Branch 1 taken 26 times.
1427 for(int32_t i=0; i<bosMAX; i++)
1768 {
1769 // If this bit is set, decrement the bit counter
1770
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1265 times.
1401 if(COOLSCROLL&(1<<i))
1771 1265 bitCounter--;
1772
1773 // When the counter hits 0, return a value based on
1774 // which bit it stopped on.
1775 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1776
2/2
✓ Branch 0 taken 1109 times.
✓ Branch 1 taken 292 times.
1401 if(bitCounter==0)
1777 1109 return i;
1778 292 }
1779
1780 // Shouldn't be necessary, but the compiler might complain, at least
1781 26 return bosCIRCLE;
1782 1135 }
1783
1784 311 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1785 {
1786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
311 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1787
1788 311 int32_t w=256, h=224;
1789 311 int32_t blockrows=28, blockcolumns=32;
1790 311 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1791
1792
2/2
✓ Branch 0 taken 8708 times.
✓ Branch 1 taken 311 times.
9019 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1793 {
1794
2/2
✓ Branch 0 taken 278656 times.
✓ Branch 1 taken 8708 times.
287364 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1795 {
1796
2/2
✓ Branch 0 taken 148380 times.
✓ Branch 1 taken 130276 times.
278656 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1797 278656 }
1798 8708 }
1799
1800 311 black_opening_count = 66;
1801 311 black_opening_x = x;
1802 311 black_opening_y = y;
1803 311 lensclk = 0;
1804 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1805
1806
1807
1/2
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
311 if(black_opening_shape == bosFADEBLACK)
1808 {
1809 refreshTints();
1810 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1811 }
1812
1/2
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
311 if(wait)
1813 {
1814 FFCore.warpScriptCheck();
1815 for(int32_t i=0; i<66; i++)
1816 {
1817 draw_screen(tmpscr);
1818 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1819 advanceframe(true);
1820
1821 if(Quit)
1822 {
1823 break;
1824 }
1825 }
1826 }
1827 311 }
1828
1829 824 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1830 {
1831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1832
1833 824 int32_t w=256, h=224;
1834 824 int32_t blockrows=28, blockcolumns=32;
1835 824 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1836
1837
2/2
✓ Branch 0 taken 23072 times.
✓ Branch 1 taken 824 times.
23896 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1838 {
1839
2/2
✓ Branch 0 taken 738304 times.
✓ Branch 1 taken 23072 times.
761376 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1840 {
1841
2/2
✓ Branch 0 taken 335487 times.
✓ Branch 1 taken 402817 times.
738304 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1842 738304 }
1843 23072 }
1844
1845 824 black_opening_count = -66;
1846 824 black_opening_x = x;
1847 824 black_opening_y = y;
1848 824 lensclk = 0;
1849
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(black_opening_shape == bosFADEBLACK)
1850 {
1851 refreshTints();
1852 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1853 }
1854
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 629 times.
824 if(wait)
1855 {
1856 629 FFCore.warpScriptCheck();
1857
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 41514 times.
42143 for(int32_t i=0; i<66; i++)
1858 {
1859 41514 draw_screen(tmpscr);
1860 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1861 41514 advanceframe(true);
1862
1863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41514 times.
41514 if(Quit)
1864 {
1865 break;
1866 }
1867 41514 }
1868 629 }
1869 824 }
1870
1871 74910 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1872 {
1873 74910 clear_to_color(tmp_scr,BLACK);
1874 74910 int32_t w=256, h=224;
1875
1876
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 2838 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70554 times.
74910 switch(black_opening_shape)
1877 {
1878 case bosOVAL:
1879 {
1880 858 double new_w=(w/2)+abs(w/2-x);
1881 858 double new_h=(h/2)+abs(h/2-y);
1882 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1883 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1884 858 break;
1885 }
1886
1887 case bosTRIANGLE:
1888 {
1889 660 double new_w=(w/2)+abs(w/2-x);
1890 660 double new_h=(h/2)+abs(h/2-y);
1891 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1892 660 double P2= (PI/2);
1893 660 double P23=(2*PI/3);
1894 660 double P43=(4*PI/3);
1895 660 double Pa= (-4*PI*a/(3*max_a));
1896 660 double angle=P2+Pa;
1897 660 double a0=angle;
1898 660 double a2=angle+P23;
1899 660 double a4=angle+P43;
1900 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1901 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1902 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1903 0);
1904 660 break;
1905 }
1906
1907 case bosSMAS:
1908 {
1909
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 1386 times.
2838 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1910
1911
2/2
✓ Branch 0 taken 79464 times.
✓ Branch 1 taken 2838 times.
82302 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1912 {
1913
2/2
✓ Branch 0 taken 635712 times.
✓ Branch 1 taken 79464 times.
715176 for(int32_t linerow=0; linerow<8; ++linerow)
1914 {
1915 635712 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1916
1917
2/2
✓ Branch 0 taken 20342784 times.
✓ Branch 1 taken 635712 times.
20978496 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1918 {
1919 61028352 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1920
6/6
✓ Branch 0 taken 14117840 times.
✓ Branch 1 taken 6224944 times.
✓ Branch 2 taken 13330568 times.
✓ Branch 3 taken 7012216 times.
✓ Branch 4 taken 7105624 times.
✓ Branch 5 taken 6224944 times.
20342784 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1921 20342784 [linerow];
1922 20342784 ++triangleline;
1923
1924
2/2
✓ Branch 0 taken 17799936 times.
✓ Branch 1 taken 2542848 times.
20342784 if(linerow==0)
1925 {
1926 2542848 }
1927 20342784 }
1928 635712 }
1929 79464 }
1930
1931 2838 break;
1932 }
1933
1934 case bosFADEBLACK:
1935 {
1936 if(black_opening_count<0)
1937 {
1938 black_fade(zc_min(-black_opening_count,63));
1939 }
1940 else if(black_opening_count>0)
1941 {
1942 black_fade(63-zc_max(black_opening_count-3,0));
1943 }
1944 else black_fade(0);
1945 return; //no blitting from tmp_scr!
1946 }
1947
1948 70554 case bosCIRCLE:
1949 default:
1950 {
1951 70554 double new_w=(w/2)+abs(w/2-x);
1952 70554 double new_h=(h/2)+abs(h/2-y);
1953 70554 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1954 //circlefill(tmp_scr,x,y,a<<3,0);
1955 70554 circlefill(tmp_scr,x,y,r,0);
1956 70554 break;
1957 }
1958 }
1959
1960 74910 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1961 74910 }
1962
1963
1964 void black_fade(int32_t fadeamnt)
1965 {
1966 for(int32_t i=0; i < 0xEF; i++)
1967 {
1968 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1969 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1970 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1971 }
1972
1973 refreshpal = true;
1974 }
1975
1976 //----------------------------------------------------------------
1977
1978 32849997 bool item_disabled(int32_t item) //is this item disabled?
1979 {
1980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32849997 times.
32849997 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1981 }
1982
1983 6702390 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1984 {
1985
2/2
✓ Branch 0 taken 80417 times.
✓ Branch 1 taken 6621973 times.
6702390 if(current_item(item_type, true) >=item)
1986 {
1987 80417 return true;
1988 }
1989
1990 6621973 return false;
1991 6702390 }
1992
1993 27648375 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1994 {
1995
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5064879 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3051917 times.
✓ Branch 6 taken 14693506 times.
✓ Branch 7 taken 4803349 times.
✓ Branch 8 taken 34724 times.
27648375 switch(item_type)
1996 {
1997 case itype_bomb:
1998 case itype_sbomb:
1999 {
2000 int32_t itemid = getItemID(itemsbuf, item_type, it);
2001
2002 if(itemid == -1)
2003 return false;
2004
2005 return (game->get_item(itemid));
2006 }
2007
2008 case itype_clock:
2009 {
2010 5064879 int32_t itemid = getItemID(itemsbuf, item_type, it);
2011
2012
2/4
✓ Branch 0 taken 5064879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5064879 times.
✗ Branch 3 not taken.
5064879 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2013 return (game->get_item(itemid));
2014 5064879 return Hero.getClock()?1:0;
2015 }
2016
2017 case itype_key:
2018 return (game->get_keys()>0);
2019
2020 case itype_magiccontainer:
2021 return (game->get_maxmagic()>=game->get_mp_per_block());
2022
2023 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2024 {
2025
1/3
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3051917 switch(it)
2026 {
2027 case -2:
2028 {
2029 for(int32_t i=0; i<MAXLEVELS; i++)
2030 {
2031 if(game->lvlitems[i]&liTRIFORCE)
2032 {
2033 return true;
2034 }
2035 }
2036
2037 return false;
2038 }
2039
2040 case -1:
2041 return (game->lvlitems[dlevel]&liTRIFORCE);
2042
2043 default:
2044
2/4
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3051917 times.
3051917 if(it>=0&&it<MAXLEVELS)
2045 {
2046 3051917 return (game->lvlitems[it]&liTRIFORCE);
2047 }
2048
2049 break;
2050 }
2051
2052 return 0;
2053 }
2054
2055 case itype_map: //it: -2=any, -1=current level, other=that level
2056 {
2057
1/3
✓ Branch 0 taken 14693506 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
14693506 switch(it)
2058 {
2059 case -2:
2060 {
2061 for(int32_t i=0; i<MAXLEVELS; i++)
2062 {
2063 if(game->lvlitems[i]&liMAP)
2064 {
2065 return true;
2066 }
2067 }
2068
2069 return false;
2070 }
2071
2072 case -1:
2073 return (game->lvlitems[dlevel]&liMAP)!=0;
2074
2075 default:
2076
2/4
✓ Branch 0 taken 14693506 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14693506 times.
14693506 if(it>=0&&it<MAXLEVELS)
2077 {
2078 14693506 return (game->lvlitems[it]&liMAP)!=0;
2079 }
2080
2081 break;
2082 }
2083
2084 return 0;
2085 }
2086
2087 case itype_compass: //it: -2=any, -1=current level, other=that level
2088 {
2089
1/3
✓ Branch 0 taken 4803349 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4803349 switch(it)
2090 {
2091 case -2:
2092 {
2093 for(int32_t i=0; i<MAXLEVELS; i++)
2094 {
2095 if(game->lvlitems[i]&liCOMPASS)
2096 {
2097 return true;
2098 }
2099 }
2100
2101 return false;
2102 }
2103
2104 case -1:
2105 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2106
2107 default:
2108
2/4
✓ Branch 0 taken 4803349 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4803349 times.
✗ Branch 3 not taken.
4803349 if(it>=0&&it<MAXLEVELS)
2109 {
2110 4803349 return (game->lvlitems[it]&liCOMPASS)!=0;
2111 }
2112
2113 break;
2114 }
2115 return 0;
2116 }
2117
2118 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2119 {
2120
1/3
✓ Branch 0 taken 34724 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
34724 switch(it)
2121 {
2122 case -2:
2123 {
2124 for(int32_t i=0; i<MAXLEVELS; i++)
2125 {
2126 if(game->lvlitems[i]&liBOSSKEY)
2127 {
2128 return true;
2129 }
2130 }
2131
2132 return false;
2133 }
2134
2135 case -1:
2136 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2137
2138 default:
2139
2/4
✓ Branch 0 taken 34724 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34724 times.
34724 if(it>=0&&it<MAXLEVELS)
2140 {
2141 34724 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2142 }
2143 break;
2144 }
2145 return 0;
2146 }
2147
2148 default:
2149 //it=(1<<(it-1));
2150 /*if (item_type>=itype_max)
2151 {
2152 enter_sys_pal();
2153 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2154 exit_sys_pal();
2155
2156 return false;
2157 }*/
2158 int32_t itemid = getItemID(itemsbuf, item_type, it);
2159
2160 if(itemid == -1)
2161 return false;
2162
2163 return game->get_item(itemid);
2164 }
2165 27648375 }
2166
2167
2168 86407928 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2169 {
2170
9/9
✓ Branch 0 taken 5064879 times.
✓ Branch 1 taken 45888896 times.
✓ Branch 2 taken 5064879 times.
✓ Branch 3 taken 5064879 times.
✓ Branch 4 taken 5064879 times.
✓ Branch 5 taken 5064879 times.
✓ Branch 6 taken 5064879 times.
✓ Branch 7 taken 5064879 times.
✓ Branch 8 taken 5064879 times.
86407928 switch(item_type)
2171 {
2172 case itype_clock:
2173 {
2174 5064879 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2175
2176
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5064879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5064879 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2177 return itemsbuf[maxid].fam_type;
2178
2179 5064879 return has_item(itype_clock,1) ? 1 : 0;
2180 }
2181
2182 case itype_key:
2183 5064879 return game->get_keys();
2184
2185 case itype_lkey:
2186 5064879 return game->lvlkeys[get_dlevel()];
2187
2188 case itype_magiccontainer:
2189 5064879 return game->get_maxmagic()/game->get_mp_per_block();
2190
2191 case itype_triforcepiece:
2192 {
2193 5064879 int32_t count=0;
2194
2195
2/2
✓ Branch 0 taken 2593218048 times.
✓ Branch 1 taken 5064879 times.
2598282927 for(int32_t i=0; i<MAXLEVELS; i++)
2196 {
2197 2593218048 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2198 2593218048 }
2199
2200 5064879 return count;
2201 }
2202
2203 case itype_map:
2204 {
2205 5064879 int32_t count=0;
2206
2207
2/2
✓ Branch 0 taken 2593218048 times.
✓ Branch 1 taken 5064879 times.
2598282927 for(int32_t i=0; i<MAXLEVELS; i++)
2208 {
2209 2593218048 count+=(game->lvlitems[i]&liMAP)?1:0;
2210 2593218048 }
2211
2212 5064879 return count;
2213 }
2214
2215 case itype_compass:
2216 {
2217 5064879 int32_t count=0;
2218
2219
2/2
✓ Branch 0 taken 2593218048 times.
✓ Branch 1 taken 5064879 times.
2598282927 for(int32_t i=0; i<MAXLEVELS; i++)
2220 {
2221 2593218048 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2222 2593218048 }
2223
2224 5064879 return count;
2225 }
2226
2227 case itype_bosskey:
2228 {
2229 5064879 int32_t count=0;
2230
2231
2/2
✓ Branch 0 taken 2593218048 times.
✓ Branch 1 taken 5064879 times.
2598282927 for(int32_t i=0; i<MAXLEVELS; i++)
2232 {
2233 2593218048 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2234 2593218048 }
2235
2236 5064879 return count;
2237 }
2238
2239 default:
2240 45888896 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2241
2242
2/2
✓ Branch 0 taken 8709356 times.
✓ Branch 1 taken 37179540 times.
45888896 if(maxid == -1)
2243 37179540 return 0;
2244
2245 8709356 return itemsbuf[maxid].fam_type;
2246 }
2247 86407928 }
2248
2249 79705538 int32_t current_item(int32_t item_type) //item currently being used
2250 {
2251 79705538 return current_item(item_type, true);
2252 }
2253
2254 38 std::map<int32_t, int32_t> itemcache;
2255
2256 // Not actually used by anything at the moment...
2257 void removeFromItemCache(int32_t itemclass)
2258 {
2259 itemcache.erase(itemclass);
2260 }
2261
2262 24296 void flushItemCache()
2263 {
2264 24296 itemcache.clear();
2265
2266 //also fix the active subscreen if items were deleted -DD
2267
1/2
✓ Branch 0 taken 24296 times.
✗ Branch 1 not taken.
24296 if(game != NULL)
2268 {
2269 24296 verifyBothWeapons();
2270 24296 load_Sitems(&QMisc);
2271 24296 }
2272 24296 }
2273
2274 // This is used often, so it should be as direct as possible.
2275 2823123522 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2276 {
2277
2/2
✓ Branch 0 taken 2764734027 times.
✓ Branch 1 taken 58389495 times.
2823123522 if(jinx_check)
2278 {
2279
4/4
✓ Branch 0 taken 38228293 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 34564629 times.
✓ Branch 3 taken 3663664 times.
58389495 if(!(HeroSwordClk() || HeroItemClk()))
2280 34564629 jinx_check = false; //not jinxed
2281 58389495 }
2282
4/4
✓ Branch 0 taken 2799003664 times.
✓ Branch 1 taken 24119858 times.
✓ Branch 2 taken 23650363 times.
✓ Branch 3 taken 2775353301 times.
2823123522 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2283 {
2284 2775353301 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2285
2286
2/2
✓ Branch 0 taken 2762949416 times.
✓ Branch 1 taken 12403885 times.
2775353301 if(res != itemcache.end())
2287 2762949416 return res->second;
2288 12403885 }
2289
2290 60174106 int32_t result = -1;
2291 60174106 int32_t highestlevel = -1;
2292
2293
2/2
✓ Branch 0 taken 15404571136 times.
✓ Branch 1 taken 60174106 times.
15464745242 for(int32_t i=0; i<MAXITEMS; i++)
2294 {
2295
5/6
✓ Branch 0 taken 1197682361 times.
✓ Branch 1 taken 14206888775 times.
✓ Branch 2 taken 17819172 times.
✓ Branch 3 taken 1179863189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17819172 times.
15404571136 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2296 {
2297
4/4
✓ Branch 0 taken 5189642 times.
✓ Branch 1 taken 12629530 times.
✓ Branch 2 taken 1358189 times.
✓ Branch 3 taken 16460983 times.
17819172 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2298 {
2299 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2300
2/2
✓ Branch 0 taken 16460824 times.
✓ Branch 1 taken 159 times.
16460983 if(!checkmagiccost(i))
2301 {
2302
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 147 times.
159 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2303 12 }
2304 16460836 }
2305
6/6
✓ Branch 0 taken 15432439 times.
✓ Branch 1 taken 2386586 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2129898 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 759329 times.
17819025 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2306 {
2307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 759329 times.
759329 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2308 759329 continue;
2309 }
2310
2311
2/2
✓ Branch 0 taken 237659 times.
✓ Branch 1 taken 16822037 times.
17059696 if(itemsbuf[i].fam_type >= highestlevel)
2312 {
2313 16822037 highestlevel = itemsbuf[i].fam_type;
2314 16822037 result=i;
2315 16822037 }
2316 17059696 }
2317 15403811660 }
2318
2319
2/2
✓ Branch 0 taken 23824866 times.
✓ Branch 1 taken 36349240 times.
60174106 if(!jinx_check) //Can't cache jinx_check results
2320 36349240 itemcache[itemtype] = result;
2321 60174106 return result;
2322 2823123522 }
2323
2324 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2325 2799616102 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2326 {
2327 2799616102 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2328
2/2
✓ Branch 0 taken 34882075 times.
✓ Branch 1 taken 2764734027 times.
2799616102 if(!jinx_check) //If not already a jinx-immune-only check...
2329 {
2330 //And the player IS jinxed...
2331
4/4
✓ Branch 0 taken 2744838409 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3611802 times.
✓ Branch 3 taken 2741226607 times.
2764734027 if(HeroSwordClk() || HeroItemClk())
2332 {
2333 //Then do a jinx-immune-only check here
2334 23507420 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2335 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2336 //Should NOT need a compat rule, as this should always return -1 in old quests.
2337
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22404776 times.
23507420 if(ret2 > -1) return ret2;
2338 22404776 }
2339 2763631383 }
2340 2798513458 return ret;
2341 2799616102 }
2342 17625756 int32_t current_item_power(int32_t itemtype)
2343 {
2344 17625756 int32_t result = current_item_id(itemtype,true);
2345
2/2
✓ Branch 0 taken 13117036 times.
✓ Branch 1 taken 4508720 times.
17625756 return (result<0) ? 0 : itemsbuf[result].power;
2346 }
2347
2348 7 int32_t heart_container_id()
2349 {
2350
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2351 {
2352
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2353 {
2354 7 return i;
2355 }
2356 196 }
2357 return -1;
2358 7 }
2359
2360 5064879 int32_t item_tile_mod()
2361 {
2362 5064879 int32_t tile=0;
2363
2364
2/2
✓ Branch 0 taken 1053836 times.
✓ Branch 1 taken 4011043 times.
5064879 if(game->get_bombs())
2365 {
2366 4011043 int32_t itemid = current_item_id(itype_bomb,false);
2367
3/4
✓ Branch 0 taken 3929984 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3929984 times.
4011043 if(itemid > -1 && checkbunny(itemid))
2368 3929984 tile+=itemsbuf[itemid].ltm;
2369 4011043 }
2370
2371
2/2
✓ Branch 0 taken 3894445 times.
✓ Branch 1 taken 1170434 times.
5064879 if(game->get_sbombs())
2372 {
2373 1170434 int32_t itemid = current_item_id(itype_sbomb,false);
2374
3/4
✓ Branch 0 taken 1169006 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1169006 times.
1170434 if(itemid > -1 && checkbunny(itemid))
2375 1169006 tile+=itemsbuf[itemid].ltm;
2376 1170434 }
2377
2378
2/2
✓ Branch 0 taken 4959875 times.
✓ Branch 1 taken 105004 times.
5064879 if(current_item(itype_clock))
2379 {
2380 105004 int32_t itemid =
2381
1/2
✓ Branch 0 taken 105004 times.
✗ Branch 1 not taken.
105004 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2382 ? iClock
2383 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2384
2/4
✓ Branch 0 taken 105004 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105004 times.
105004 if(itemid > -1 && checkbunny(itemid))
2385 105004 tile+=itemsbuf[itemid].ltm;
2386 105004 }
2387
2388
2/2
✓ Branch 0 taken 4018967 times.
✓ Branch 1 taken 1045912 times.
5064879 if(current_item(itype_key))
2389 {
2390 1045912 int32_t itemid =
2391
1/2
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
1045912 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2392 ? iKey
2393 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2394
2/4
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1045912 times.
1045912 if(itemid > -1 && checkbunny(itemid))
2395 1045912 tile+=itemsbuf[itemid].ltm;
2396 1045912 }
2397
2398
2/2
✓ Branch 0 taken 4892348 times.
✓ Branch 1 taken 172531 times.
5064879 if(current_item(itype_lkey))
2399 {
2400 172531 int32_t itemid =
2401
2/2
✓ Branch 0 taken 171621 times.
✓ Branch 1 taken 910 times.
172531 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2402 ? iLevelKey
2403 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2404
2/4
✓ Branch 0 taken 172531 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 172531 times.
172531 if(itemid > -1 && checkbunny(itemid))
2405 172531 tile+=itemsbuf[itemid].ltm;
2406 172531 }
2407
2408
2/2
✓ Branch 0 taken 1029403 times.
✓ Branch 1 taken 4035476 times.
5064879 if(current_item(itype_map))
2409 {
2410 4035476 int32_t itemid =
2411
2/2
✓ Branch 0 taken 4034690 times.
✓ Branch 1 taken 786 times.
4035476 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2412 ? iMap
2413 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2414
2/4
✓ Branch 0 taken 4035476 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4035476 times.
4035476 if(itemid > -1 && checkbunny(itemid))
2415 4035476 tile+=itemsbuf[itemid].ltm;
2416 4035476 }
2417
2418
2/2
✓ Branch 0 taken 1007521 times.
✓ Branch 1 taken 4057358 times.
5064879 if(current_item(itype_compass))
2419 {
2420 4057358 int32_t itemid =
2421
2/2
✓ Branch 0 taken 3976299 times.
✓ Branch 1 taken 81059 times.
4057358 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2422 ? iCompass
2423 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2424
2/4
✓ Branch 0 taken 4057358 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4057358 times.
4057358 if(itemid > -1 && checkbunny(itemid))
2425 4057358 tile+=itemsbuf[itemid].ltm;
2426 4057358 }
2427
2428
2/2
✓ Branch 0 taken 3195675 times.
✓ Branch 1 taken 1869204 times.
5064879 if(current_item(itype_bosskey))
2429 {
2430 1869204 int32_t itemid =
2431
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2432 ? iBossKey
2433 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2434
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2435 1869204 tile+=itemsbuf[itemid].ltm;
2436 1869204 }
2437
2438
2/2
✓ Branch 0 taken 2908630 times.
✓ Branch 1 taken 2156249 times.
5064879 if(current_item(itype_magiccontainer))
2439 {
2440 2156249 int32_t itemid =
2441
2/2
✓ Branch 0 taken 2063262 times.
✓ Branch 1 taken 92987 times.
2156249 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2442 ? iMagicC
2443 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2444
3/4
✓ Branch 0 taken 2156249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2154379 times.
2156249 if(itemid > -1 && checkbunny(itemid))
2445 2154379 tile+=itemsbuf[itemid].ltm;
2446 2156249 }
2447
2448
2/2
✓ Branch 0 taken 1365586 times.
✓ Branch 1 taken 3699293 times.
5064879 if(current_item(itype_triforcepiece))
2449 {
2450 3699293 int32_t itemid =
2451
1/2
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
3699293 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2452 ? iTriforce
2453 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2454
2/4
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3699293 times.
3699293 if(itemid > -1 && checkbunny(itemid))
2455 3699293 tile+=itemsbuf[itemid].ltm;
2456 3699293 }
2457
2458
2/2
✓ Branch 0 taken 5064879 times.
✓ Branch 1 taken 2593218048 times.
2598282927 for(int32_t i=0; i<itype_max; i++)
2459 {
2460
2/2
✓ Branch 0 taken 2541357056 times.
✓ Branch 1 taken 51860992 times.
2593218048 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2461 {
2462
2/2
✓ Branch 0 taken 1012910 times.
✓ Branch 1 taken 50848082 times.
51860992 switch(i)
2463 {
2464 case itype_bomb:
2465 case itype_sbomb:
2466 case itype_clock:
2467 case itype_key:
2468 case itype_lkey:
2469 case itype_map:
2470 case itype_compass:
2471 case itype_bosskey:
2472 case itype_magiccontainer:
2473 case itype_triforcepiece:
2474 1012910 continue; //already handled
2475 }
2476 50848082 }
2477 2592205138 int32_t itemid = current_item_id(i,false);
2478
2/2
✓ Branch 0 taken 2587140259 times.
✓ Branch 1 taken 5064879 times.
2592205138 if(i == itype_shield)
2479 5064879 itemid = getCurrentShield(false);
2480
2481
4/4
✓ Branch 0 taken 70903123 times.
✓ Branch 1 taken 2521302015 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 70802142 times.
2592205138 if(itemid < 0 || !checkbunny(itemid))
2482 2521402996 continue;
2483
2484 70802142 itemdata const& itm = itemsbuf[itemid];
2485
2486
2/2
✓ Branch 0 taken 66352070 times.
✓ Branch 1 taken 4450072 times.
70802142 switch(itm.family)
2487 {
2488 case itype_shield:
2489
1/2
✓ Branch 0 taken 4450072 times.
✗ Branch 1 not taken.
4450072 if(itm.flags & ITEM_FLAG9) //active shield
2490 {
2491 if(!usingActiveShield(itemid))
2492 {
2493 tile+=itm.misc6; //'Inactive PTM'
2494 continue;
2495 }
2496 }
2497 4450072 break;
2498 }
2499
2500 70802142 tile+=itm.ltm;
2501 70802142 }
2502
2503 5064879 return tile;
2504 }
2505
2506 5064879 int32_t bunny_tile_mod()
2507 {
2508
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 5063009 times.
5064879 if(Hero.BunnyClock())
2509 {
2510 1870 return game->get_bunny_ltm();
2511 }
2512 5063009 return 0;
2513 5064879 }
2514
2515 // Hints are drawn on a separate layer to combo reveals.
2516 16332 void draw_lens_under(BITMAP *dest, bool layer)
2517 {
2518 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2519 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2520 //Lens flag 3: Don't show armos/chest/dive items
2521 //Lens flag 4: Show Raft Paths
2522 //Lens flag 5: Show Invisible Enemies
2523
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2524
2525 16332 int32_t strike_hint_table[11]=
2526 {
2527 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2528 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2529 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2530 };
2531
2532 // int32_t page = tmpscr->cpage;
2533 {
2534 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2535 // int32_t temptimer=0;
2536 16332 int32_t tempitem, tempweapon=0;
2537 16332 strike_hint=strike_hint_table[strike_hint_counter];
2538
2539
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2540 {
2541 492 strike_hint_timer=0;
2542 492 strike_hint_counter=((strike_hint_counter+1)%11);
2543 492 }
2544
2545 16332 ++strike_hint_timer;
2546
2547
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2548 {
2549 2874432 int32_t x = (i & 15) << 4;
2550 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2551 2874432 int32_t tempitemx=-16, tempitemy=-16;
2552 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2553
2554
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2555 {
2556 5748864 int32_t checkflag=0;
2557
2558
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2559 {
2560 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2561 2874432 }
2562 else
2563 {
2564 2874432 checkflag=tmpscr->sflag[i];
2565 }
2566
2567
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2568 {
2569
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2570 {
2571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2572 906 }
2573 else
2574 {
2575 192 checkflag = strike_hint;
2576 }
2577 1098 }
2578
2579
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2580 {
2581 case 0:
2582 case mfZELDA:
2583 case mfPUSHED:
2584 case mfENEMY0:
2585 case mfENEMY1:
2586 case mfENEMY2:
2587 case mfENEMY3:
2588 case mfENEMY4:
2589 case mfENEMY5:
2590 case mfENEMY6:
2591 case mfENEMY7:
2592 case mfENEMY8:
2593 case mfENEMY9:
2594 case mfSINGLE:
2595 case mfSINGLE16:
2596 case mfNOENEMY:
2597 case mfTRAP_H:
2598 case mfTRAP_V:
2599 case mfTRAP_4:
2600 case mfTRAP_LR:
2601 case mfTRAP_UD:
2602 case mfNOGROUNDENEMY:
2603 case mfNOBLOCKS:
2604 case mfSCRIPT1:
2605 case mfSCRIPT2:
2606 case mfSCRIPT3:
2607 case mfSCRIPT4:
2608 case mfSCRIPT5:
2609 case mfSCRIPT6:
2610 case mfSCRIPT7:
2611 case mfSCRIPT8:
2612 case mfSCRIPT9:
2613 case mfSCRIPT10:
2614 case mfSCRIPT11:
2615 case mfSCRIPT12:
2616 case mfSCRIPT13:
2617 case mfSCRIPT14:
2618 case mfSCRIPT15:
2619 case mfSCRIPT16:
2620 case mfSCRIPT17:
2621 case mfSCRIPT18:
2622 case mfSCRIPT19:
2623 case mfSCRIPT20:
2624 case mfPITHOLE:
2625 case mfPITFALLFLOOR:
2626 case mfLAVA:
2627 case mfICE:
2628 case mfICEDAMAGE:
2629 case mfDAMAGE1:
2630 case mfDAMAGE2:
2631 case mfDAMAGE4:
2632 case mfDAMAGE8:
2633 case mfDAMAGE16:
2634 case mfDAMAGE32:
2635 case mfFREEZEALL:
2636 case mfFREZEALLANSFFCS:
2637 case mfFREEZEFFCSOLY:
2638 case mfSCRITPTW1TRIG:
2639 case mfSCRITPTW2TRIG:
2640 case mfSCRITPTW3TRIG:
2641 case mfSCRITPTW4TRIG:
2642 case mfSCRITPTW5TRIG:
2643 case mfSCRITPTW6TRIG:
2644 case mfSCRITPTW7TRIG:
2645 case mfSCRITPTW8TRIG:
2646 case mfSCRITPTW9TRIG:
2647 case mfSCRITPTW10TRIG:
2648 case mfTROWEL:
2649 case mfTROWELNEXT:
2650 case mfTROWELSPECIALITEM:
2651 case mfSLASHPOT:
2652 case mfLIFTPOT:
2653 case mfLIFTORSLASH:
2654 case mfLIFTROCK:
2655 case mfLIFTROCKHEAVY:
2656 case mfDROPITEM:
2657 case mfSPECIALITEM:
2658 case mfDROPKEY:
2659 case mfDROPLKEY:
2660 case mfDROPCOMPASS:
2661 case mfDROPMAP:
2662 case mfDROPBOSSKEY:
2663 case mfSPAWNNPC:
2664 case mfSWITCHHOOK:
2665 case mfSIDEVIEWLADDER:
2666 case mfSIDEVIEWPLATFORM:
2667 case mfNOENEMYSPAWN:
2668 case mfENEMYALL:
2669 case mfNOMIRROR:
2670 case mfUNSAFEGROUND:
2671 case mf168:
2672 case mf169:
2673 case mf170:
2674 case mf171:
2675 case mf172:
2676 case mf173:
2677 case mf174:
2678 case mf175:
2679 case mf176:
2680 case mf177:
2681 case mf178:
2682 case mf179:
2683 case mf180:
2684 case mf181:
2685 case mf182:
2686 case mf183:
2687 case mf184:
2688 case mf185:
2689 case mf186:
2690 case mf187:
2691 case mf188:
2692 case mf189:
2693 case mf190:
2694 case mf191:
2695 case mf192:
2696 case mf193:
2697 case mf194:
2698 case mf195:
2699 case mf196:
2700 case mf197:
2701 case mf198:
2702 case mf199:
2703 case mf200:
2704 case mf201:
2705 case mf202:
2706 case mf203:
2707 case mf204:
2708 case mf205:
2709 case mf206:
2710 case mf207:
2711 case mf208:
2712 case mf209:
2713 case mf210:
2714 case mf211:
2715 case mf212:
2716 case mf213:
2717 case mf214:
2718 case mf215:
2719 case mf216:
2720 case mf217:
2721 case mf218:
2722 case mf219:
2723 case mf220:
2724 case mf221:
2725 case mf222:
2726 case mf223:
2727 case mf224:
2728 case mf225:
2729 case mf226:
2730 case mf227:
2731 case mf228:
2732 case mf229:
2733 case mf230:
2734 case mf231:
2735 case mf232:
2736 case mf233:
2737 case mf234:
2738 case mf235:
2739 case mf236:
2740 case mf237:
2741 case mf238:
2742 case mf239:
2743 case mf240:
2744 case mf241:
2745 case mf242:
2746 case mf243:
2747 case mf244:
2748 case mf245:
2749 case mf246:
2750 case mf247:
2751 case mf248:
2752 case mf249:
2753 case mf250:
2754 case mf251:
2755 case mf252:
2756 case mf253:
2757 case mf254:
2758 case mfEXTENDED:
2759 5706470 break;
2760
2761 case mfPUSHUD:
2762 case mfPUSHLR:
2763 case mfPUSH4:
2764 case mfPUSHU:
2765 case mfPUSHD:
2766 case mfPUSHL:
2767 case mfPUSHR:
2768 case mfPUSHUDNS:
2769 case mfPUSHLRNS:
2770 case mfPUSH4NS:
2771 case mfPUSHUNS:
2772 case mfPUSHDNS:
2773 case mfPUSHLNS:
2774 case mfPUSHRNS:
2775 case mfPUSHUDINS:
2776 case mfPUSHLRINS:
2777 case mfPUSH4INS:
2778 case mfPUSHUINS:
2779 case mfPUSHDINS:
2780 case mfPUSHLINS:
2781 case mfPUSHRINS:
2782
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2783
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2784 {
2785 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2786 }
2787
2788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2789
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2790 {
2791
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2792 {
2793
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2794 {
2795 case cPUSH_HEAVY:
2796 case cPUSH_HW:
2797 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2798 72 tempitemx=x, tempitemy=y;
2799
2800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2801 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2802
2803 72 break;
2804
2805 case cPUSH_HEAVY2:
2806 case cPUSH_HW2:
2807 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2808 63 tempitemx=x, tempitemy=y;
2809
2810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2811 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2812
2813 63 break;
2814 }
2815 1032 }
2816 2438 }
2817
2818 3148 break;
2819
2820 case mfWHISTLE:
2821
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2822 {
2823 tempitem=getItemID(itemsbuf,itype_whistle,1);
2824
2825 if(tempitem<0) break;
2826
2827 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2828 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2829 {
2830 tempitemx=x;
2831 tempitemy=y;
2832 }
2833
2834 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2835 }
2836
2837 2418 break;
2838
2839 //Why is this here?
2840 case mfFAIRY:
2841 case mfMAGICFAIRY:
2842 case mfALLFAIRY:
2843 if(hints)
2844 {
2845 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2846
2847 if(tempitem < 0) break;
2848
2849 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2850 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2851 {
2852 tempitemx=x;
2853 tempitemy=y;
2854 }
2855
2856 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2857 }
2858
2859 break;
2860
2861 case mfANYFIRE:
2862
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2863 {
2864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2865 252 }
2866 else
2867 {
2868 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2869
2870
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2871
2872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2873
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2874 {
2875 189 tempitemx=x;
2876 189 tempitemy=y;
2877 189 }
2878
2879 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2880 }
2881
2882 504 break;
2883
2884 case mfSTRONGFIRE:
2885 if(!hints)
2886 {
2887 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2888 }
2889 else
2890 {
2891 tempitem=getItemID(itemsbuf,itype_candle,2);
2892
2893 if(tempitem<0) break;
2894
2895 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2896 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2897 {
2898 tempitemx=x;
2899 tempitemy=y;
2900 }
2901
2902 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2903 }
2904
2905 break;
2906
2907 case mfMAGICFIRE:
2908 if(!hints)
2909 {
2910 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2911 }
2912 else
2913 {
2914 tempitem=getItemID(itemsbuf,itype_wand,1);
2915
2916 if(tempitem<0) break;
2917
2918 tempweapon=wFire;
2919
2920 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2921 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2922 {
2923 tempitemx=x;
2924 tempitemy=y;
2925 }
2926 else
2927 {
2928 tempweaponx=x;
2929 tempweapony=y;
2930 }
2931
2932 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2933 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2934 }
2935
2936 break;
2937
2938 case mfDIVINEFIRE:
2939 if(!hints)
2940 {
2941 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2942 }
2943 else
2944 {
2945 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2946
2947 if(tempitem<0) break;
2948
2949 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2950 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2951 {
2952 tempitemx=x;
2953 tempitemy=y;
2954 }
2955
2956 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2957 }
2958
2959 break;
2960
2961 case mfARROW:
2962
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2963 {
2964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2965 732 }
2966 else
2967 {
2968 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2969
2970
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2971
2972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2973
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2974 {
2975 61 tempitemx=x;
2976 61 tempitemy=y;
2977 61 }
2978
2979 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2980 }
2981
2982 814 break;
2983
2984 case mfSARROW:
2985 if(!hints)
2986 {
2987 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2988 }
2989 else
2990 {
2991 tempitem=getItemID(itemsbuf,itype_arrow,2);
2992
2993 if(tempitem<0) break;
2994
2995 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2996 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2997 {
2998 tempitemx=x;
2999 tempitemy=y;
3000 }
3001
3002 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3003 }
3004
3005 break;
3006
3007 case mfGARROW:
3008 if(!hints)
3009 {
3010 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3011 }
3012 else
3013 {
3014 tempitem=getItemID(itemsbuf,itype_arrow,3);
3015
3016 if(tempitem<0) break;
3017
3018 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3019 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3020 {
3021 tempitemx=x;
3022 tempitemy=y;
3023 }
3024
3025 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3026 }
3027
3028 break;
3029
3030 case mfBOMB:
3031
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3032 {
3033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3034 16 }
3035 else
3036 {
3037 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3038 17 tempweapon = wLitBomb;
3039
3040 //if (tempitem<0) break;
3041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3042
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3043 {
3044 12 tempweaponx=x;
3045 12 tempweapony=y;
3046 12 }
3047
3048 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3049 }
3050
3051 33 break;
3052
3053 case mfSBOMB:
3054
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3055 {
3056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3057 48 }
3058 else
3059 {
3060 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3061 //if (tempitem<0) break;
3062 48 tempweapon = wLitSBomb;
3063
3064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3065
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3066 {
3067 36 tempweaponx=x;
3068 36 tempweapony=y;
3069 36 }
3070
3071 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3072 }
3073
3074 96 break;
3075
3076 case mfARMOS_SECRET:
3077
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3078 {
3079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3080 12 }
3081 24 break;
3082
3083 case mfBRANG:
3084
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3085 {
3086 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3087 }
3088 else
3089 {
3090 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3091
3092
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3093
3094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3095
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3096 {
3097 4 tempitemx=x;
3098 4 tempitemy=y;
3099 4 }
3100
3101 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3102 }
3103
3104 5 break;
3105
3106 case mfMBRANG:
3107 if(!hints)
3108 {
3109 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3110 }
3111 else
3112 {
3113 tempitem=getItemID(itemsbuf,itype_brang,2);
3114
3115 if(tempitem<0) break;
3116
3117 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3118 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3119 {
3120 tempitemx=x;
3121 tempitemy=y;
3122 }
3123
3124 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3125 }
3126
3127 break;
3128
3129 case mfFBRANG:
3130 if(!hints)
3131 {
3132 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3133 }
3134 else
3135 {
3136 tempitem=getItemID(itemsbuf,itype_brang,3);
3137
3138 if(tempitem<0) break;
3139
3140 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3141 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3142 {
3143 tempitemx=x;
3144 tempitemy=y;
3145 }
3146
3147 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3148 }
3149
3150 break;
3151
3152 case mfWANDMAGIC:
3153 if(!hints)
3154 {
3155 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3156 }
3157 else
3158 {
3159 tempitem=getItemID(itemsbuf,itype_wand,1);
3160
3161 if(tempitem<0) break;
3162
3163 tempweapon=itemsbuf[tempitem].wpn3;
3164
3165 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3166 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3167 {
3168 tempitemx=x;
3169 tempitemy=y;
3170 }
3171 else
3172 {
3173 tempweaponx=x;
3174 tempweapony=y;
3175 --lens_hint_weapon[wMagic][4];
3176
3177 if(lens_hint_weapon[wMagic][4]<-8)
3178 {
3179 lens_hint_weapon[wMagic][4]=8;
3180 }
3181 }
3182
3183 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3184 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3185 }
3186
3187 break;
3188
3189 case mfREFMAGIC:
3190
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3191 {
3192 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3193 }
3194 else
3195 {
3196 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3197
3198
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3199
3200 16 tempweapon=ewMagic;
3201
3202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3203
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3204 {
3205 13 tempitemx=x;
3206 13 tempitemy=y;
3207 13 }
3208 else
3209 {
3210 3 tempweaponx=x;
3211 3 tempweapony=y;
3212
3213
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3214 {
3215 1 --lens_hint_weapon[ewMagic][4];
3216 1 }
3217 else
3218 {
3219 2 ++lens_hint_weapon[ewMagic][4];
3220 }
3221
3222
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3223 {
3224 lens_hint_weapon[ewMagic][2]=up;
3225 }
3226
3227
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3228 {
3229 2 lens_hint_weapon[ewMagic][2]=down;
3230 2 }
3231 }
3232
3233 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3234 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3235 }
3236
3237 16 break;
3238
3239 case mfREFFIREBALL:
3240
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3241 {
3242 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3243 }
3244 else
3245 {
3246 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3247
3248
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3249
3250 16 tempweapon=ewFireball;
3251
3252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3253
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3254 {
3255 12 tempitemx=x;
3256 12 tempitemy=y;
3257 12 tempweaponx=x;
3258 12 tempweapony=y;
3259 12 ++lens_hint_weapon[ewFireball][3];
3260
3261
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3262 {
3263 1 lens_hint_weapon[ewFireball][3]=-8;
3264 1 lens_hint_weapon[ewFireball][4]=8;
3265 1 }
3266
3267
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3268 {
3269 8 ++lens_hint_weapon[ewFireball][4];
3270 8 }
3271 else
3272 {
3273 4 --lens_hint_weapon[ewFireball][4];
3274 }
3275 12 }
3276
3277 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3278 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3279 }
3280
3281 16 break;
3282
3283 case mfSWORD:
3284
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3285 {
3286 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3287 }
3288 else
3289 {
3290 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3291
3292
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3293
3294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3295
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3296 {
3297 5 tempitemx=x;
3298 5 tempitemy=y;
3299 5 }
3300
3301 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3302 }
3303
3304 7 break;
3305
3306 case mfWSWORD:
3307 if(!hints)
3308 {
3309 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3310 }
3311 else
3312 {
3313 tempitem=getItemID(itemsbuf,itype_sword,2);
3314
3315 if(tempitem<0) break;
3316
3317 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3318 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3319 {
3320 tempitemx=x;
3321 tempitemy=y;
3322 }
3323
3324 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3325 }
3326
3327 break;
3328
3329 case mfMSWORD:
3330 if(!hints)
3331 {
3332 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3333 }
3334 else
3335 {
3336 tempitem=getItemID(itemsbuf,itype_sword,3);
3337
3338 if(tempitem<0) break;
3339
3340 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3341 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3342 {
3343 tempitemx=x;
3344 tempitemy=y;
3345 }
3346
3347 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3348 }
3349
3350 break;
3351
3352 case mfXSWORD:
3353 if(!hints)
3354 {
3355 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3356 }
3357 else
3358 {
3359 tempitem=getItemID(itemsbuf,itype_sword,4);
3360
3361 if(tempitem<0) break;
3362
3363 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3364 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3365 {
3366 tempitemx=x;
3367 tempitemy=y;
3368 }
3369
3370 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3371 }
3372
3373 break;
3374
3375 case mfSWORDBEAM:
3376
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3377 {
3378 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3379 }
3380 else
3381 {
3382 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3383
3384
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3385
3386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3387
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3388 {
3389 11 tempitemx=x;
3390 11 tempitemy=y;
3391 11 }
3392
3393 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3394 }
3395
3396 16 break;
3397
3398 case mfWSWORDBEAM:
3399 if(!hints)
3400 {
3401 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3402 }
3403 else
3404 {
3405 tempitem=getItemID(itemsbuf,itype_sword,2);
3406
3407 if(tempitem<0) break;
3408
3409 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3410 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3411 {
3412 tempitemx=x;
3413 tempitemy=y;
3414 }
3415
3416 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3417 }
3418
3419 break;
3420
3421 case mfMSWORDBEAM:
3422 if(!hints)
3423 {
3424 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3425 }
3426 else
3427 {
3428 tempitem=getItemID(itemsbuf,itype_sword,3);
3429
3430 if(tempitem<0) break;
3431
3432 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3433 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3434 {
3435 tempitemx=x;
3436 tempitemy=y;
3437 }
3438
3439 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3440 }
3441
3442 break;
3443
3444 case mfXSWORDBEAM:
3445 if(!hints)
3446 {
3447 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3448 }
3449 else
3450 {
3451 tempitem=getItemID(itemsbuf,itype_sword,4);
3452
3453 if(tempitem<0) break;
3454
3455 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3456 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3457 {
3458 tempitemx=x;
3459 tempitemy=y;
3460 }
3461
3462 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3463 }
3464
3465 break;
3466
3467 case mfHOOKSHOT:
3468
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3469 {
3470 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3471 }
3472 else
3473 {
3474 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3475
3476
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3477
3478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3479
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3480 {
3481 12 tempitemx=x;
3482 12 tempitemy=y;
3483 12 }
3484
3485 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3486 }
3487
3488 17 break;
3489
3490 case mfWAND:
3491
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3492 {
3493 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3494 }
3495 else
3496 {
3497 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3498
3499
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3500
3501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3502
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3503 {
3504 28 tempitemx=x;
3505 28 tempitemy=y;
3506 28 }
3507
3508 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3509 }
3510
3511 35 break;
3512
3513 case mfHAMMER:
3514
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3515 {
3516 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3517 }
3518 else
3519 {
3520 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3521
3522
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3523
3524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3525
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3526 {
3527 13 tempitemx=x;
3528 13 tempitemy=y;
3529 13 }
3530
3531 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3532 }
3533
3534 17 break;
3535
3536 case mfARMOS_ITEM:
3537 case mfDIVE_ITEM:
3538
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3539 {
3540 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3541 2064 }
3542 2064 break;
3543
3544 case 16:
3545 case 17:
3546 case 18:
3547 case 19:
3548 case 20:
3549 case 21:
3550 case 22:
3551 case 23:
3552 case 24:
3553 case 25:
3554 case 26:
3555 case 27:
3556 case 28:
3557 case 29:
3558 case 30:
3559 case 31:
3560
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3562 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3563
3564 3618 break;
3565 case mfSECRETSNEXT:
3566 if(!hints)
3567 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3568 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3569
3570 break;
3571
3572 case mfSTRIKE:
3573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3574 {
3575 906 goto special;
3576 }
3577 else
3578 {
3579 break;
3580 }
3581
3582 28640 default: goto special;
3583
3584 special:
3585
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3586 {
3587
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3588 {
3589 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3590 4913 }
3591 6549 }
3592
3593 29546 break;
3594 }
3595 5748864 }
3596 2874432 }
3597
3598
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3599 {
3600
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3601 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3602
3603
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3604 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3605
3606
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3607 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3608
3609
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3610 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3611
3612
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3613 {
3614 43 showbombeddoor(dest, 0);
3615 43 }
3616
3617
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3618 {
3619 39 showbombeddoor(dest, 1);
3620 39 }
3621
3622
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3623 {
3624 showbombeddoor(dest, 2);
3625 }
3626
3627
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3628 {
3629 37 showbombeddoor(dest, 3);
3630 37 }
3631 8166 }
3632
3633
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3634 {
3635
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3636 {
3637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3638 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3639 1123 }
3640 else
3641 {
3642
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3643 {
3644 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3645 48 int32_t tempitemx=-16;
3646 48 int32_t tempitemy=-16;
3647
3648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3649
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3650 {
3651 24 tempitemx=tmpscr->stairx;
3652 24 tempitemy=tmpscr->stairy+playing_field_offset;
3653 24 }
3654
3655 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3656 48 }
3657 }
3658 2034 }
3659 }
3660 16332 }
3661
3662 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3663
3664 7997 void draw_lens_over()
3665 {
3666 // Oh, what the heck.
3667 static BITMAP *lens_scr = NULL;
3668 static int32_t last_width = -1;
3669 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3670
3671 // Only redraw the circle if the size has changed
3672
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3673 {
3674
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3675 {
3676 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3677 5 }
3678
3679 5 clear_to_color(lens_scr, BLACK);
3680 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3681 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3682 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3683 5 last_width=width;
3684 5 }
3685
3686 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3687 7997 }
3688
3689 //----------------------------------------------------------------
3690
3691 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3692 {
3693 //recreating a big bitmap every frame is highly sluggish.
3694
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3695 30701 clear_to_color(wavebuf, BLACK);
3696 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3697
3698 int32_t ofs;
3699 // int32_t amplitude=8;
3700 // int32_t wavelength=4;
3701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3702
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3703 30701 int32_t amp2=168;
3704
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3705 30701 int32_t i=frame%amp2;
3706
3707
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3708 {
3709
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3710 {
3711 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3712 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3713 }
3714 else
3715 {
3716 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3717 }
3718
3719
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3720 {
3721
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3722 {
3723 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3724 1320388608 }
3725 5157768 }
3726 5157768 }
3727 30701 }
3728
3729 3360 void draw_fuzzy(int32_t fuzz)
3730 // draws from right half of scrollbuf to framebuf
3731 {
3732 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3733 byte *start, *si, *di;
3734
3735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if(fuzz<1)
3736 fuzz = 1;
3737
3738 3360 xstep = 128%fuzz;
3739
3740
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 2660 times.
3360 if(xstep > 0)
3741 2660 xstep = fuzz-xstep;
3742
3743 3360 ystep = 112%fuzz;
3744
3745
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 2380 times.
3360 if(ystep > 0)
3746 2380 ystep = fuzz-ystep;
3747
3748 3360 firsty = 1;
3749
3750
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 121240 times.
124600 for(y=0; y<224;)
3751 {
3752 121240 start = &(scrollbuf->line[y][256]);
3753
3754
4/4
✓ Branch 0 taken 119560 times.
✓ Branch 1 taken 754320 times.
✓ Branch 2 taken 752640 times.
✓ Branch 3 taken 121240 times.
873880 for(dy=0; dy<ystep && dy+y<224; dy++)
3755 {
3756 752640 si = start;
3757 752640 di = &(framebuf->line[y+dy][0]);
3758 752640 i = xstep;
3759 752640 firstx = 1;
3760
3761
2/2
✓ Branch 0 taken 192675840 times.
✓ Branch 1 taken 752640 times.
193428480 for(dx=0; dx<256; dx++)
3762 {
3763 192675840 *(di++) = *si;
3764
3765
2/2
✓ Branch 0 taken 162350720 times.
✓ Branch 1 taken 30325120 times.
192675840 if(++i >= fuzz)
3766 {
3767
2/2
✓ Branch 0 taken 29572480 times.
✓ Branch 1 taken 752640 times.
30325120 if(!firstx)
3768 29572480 si += fuzz;
3769 else
3770 {
3771 752640 si += fuzz-xstep;
3772 752640 firstx = 0;
3773 }
3774
3775 30325120 i = 0;
3776 30325120 }
3777 192675840 }
3778 752640 }
3779
3780
2/2
✓ Branch 0 taken 117880 times.
✓ Branch 1 taken 3360 times.
121240 if(!firsty)
3781 117880 y += fuzz;
3782 else
3783 {
3784 3360 y += ystep;
3785 3360 ystep = fuzz;
3786 3360 firsty = 0;
3787 }
3788 }
3789 3360 }
3790
3791 8116459 void updatescr(bool allowwavy)
3792 {
3793
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 8116421 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 38 times.
✗ Branch 5 not taken.
8116459 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3794
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 8116421 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
8116459 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3795
3796
2/2
✓ Branch 0 taken 8089694 times.
✓ Branch 1 taken 26765 times.
8116459 if(toogam)
3797 {
3798 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3799 26765 }
3800
3801
1/2
✓ Branch 0 taken 8116459 times.
✗ Branch 1 not taken.
8116459 if(Showpal)
3802 dump_pal(framebuf);
3803
3804
2/2
✓ Branch 0 taken 7943378 times.
✓ Branch 1 taken 173081 times.
8116459 if(!Playing)
3805 173081 black_opening_count=0;
3806
3807
2/2
✓ Branch 0 taken 8062075 times.
✓ Branch 1 taken 54384 times.
8116459 if(black_opening_count<0) //shape is opening up
3808 {
3809 54384 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3810
3811
2/4
✓ Branch 0 taken 54384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54384 times.
54384 if(Advance||(!Paused))
3812 {
3813 54384 ++black_opening_count;
3814 54384 }
3815 54384 }
3816
2/2
✓ Branch 0 taken 8041549 times.
✓ Branch 1 taken 20526 times.
8062075 else if(black_opening_count>0) //shape is closing
3817 {
3818 20526 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3819
3820
2/4
✓ Branch 0 taken 20526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20526 times.
20526 if(Advance||(!Paused))
3821 {
3822 20526 --black_opening_count;
3823 20526 }
3824 20526 }
3825
3826
3/4
✓ Branch 0 taken 8042684 times.
✓ Branch 1 taken 73775 times.
✓ Branch 2 taken 8042684 times.
✗ Branch 3 not taken.
8116459 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3827 {
3828 black_opening_shape = bosCIRCLE;
3829 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3830 refreshTints();
3831 refreshpal=true;
3832 }
3833
3834
2/2
✓ Branch 0 taken 7871547 times.
✓ Branch 1 taken 244912 times.
8116459 if(refreshpal)
3835 {
3836 244912 refreshpal=false;
3837 244912 RAMpal[253] = _RGB(0,0,0);
3838 244912 RAMpal[254] = _RGB(63,63,63);
3839 244912 hw_palette = &RAMpal;
3840 244912 update_hw_pal = true;
3841
3842 244912 create_rgb_table(&rgb_table, RAMpal, NULL);
3843 244912 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3844 244912 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3845
3846
2/2
✓ Branch 0 taken 62697472 times.
✓ Branch 1 taken 244912 times.
62942384 for(int32_t q=0; q<PAL_SIZE; q++)
3847 {
3848 62697472 trans_table2.data[0][q] = q;
3849 62697472 trans_table2.data[q][q] = q;
3850 62697472 }
3851 244912 }
3852
3853 8116459 bool clearwavy = (wavy <= 0);
3854
3855
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 8109214 times.
8116459 if(wavy <= 0)
3856 {
3857 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3858 8109214 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3859 8109214 }
3860
3861 8116459 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3862
3863
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 8085508 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
8116459 if(wavy && Playing && allowwavy)
3864 {
3865 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3866 30701 }
3867
3868
2/2
✓ Branch 0 taken 8109214 times.
✓ Branch 1 taken 7245 times.
8116459 if(clearwavy)
3869 8109214 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3870
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3871 7245 wavy--; // Wavy was set by a script. Decrement it.
3872
3873
5/6
✓ Branch 0 taken 7943378 times.
✓ Branch 1 taken 173081 times.
✓ Branch 2 taken 184496 times.
✓ Branch 3 taken 7758882 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 184496 times.
8116459 if(Playing && msgpos && !screenscrolling)
3874 {
3875
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_bg_display_buf->clip))
3876 184496 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3877
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_portrait_display_buf->clip))
3878 184496 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3879
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_txt_display_buf->clip))
3880 184496 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3881 184496 }
3882
3883 /*
3884 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3885 {
3886 BITMAP* subBmp = 0;
3887 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3888 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3889 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3890 destroy_bitmap(subBmp);
3891 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3892 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3893 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3894 }
3895 */
3896
3897
2/2
✓ Branch 0 taken 8078942 times.
✓ Branch 1 taken 37517 times.
8116459 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3898
3899
2/2
✓ Branch 0 taken 8083567 times.
✓ Branch 1 taken 32892 times.
8116459 if(nosubscr)
3900 {
3901 32892 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3902 32892 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3903 32892 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3904 32892 }
3905
3906 //TODO: Optimize blit 'overcalls' -Gleeok
3907
2/2
✓ Branch 0 taken 32892 times.
✓ Branch 1 taken 8083567 times.
8116459 BITMAP *source = nosubscr ? panorama : wavybuf;
3908 8116459 blit(source,framebuf,0,0,0,0,256,224);
3909
3910 8116459 update_hw_screen();
3911 8116459 }
3912
3913 //----------------------------------------------------------------
3914
3915 static PALETTE syspal;
3916 int32_t onGUISnapshot()
3917 {
3918 char buf[200];
3919 int32_t num=0;
3920 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3921 do
3922 {
3923 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3924 }
3925 while(num<99999 && exists(buf));
3926
3927 BITMAP *b = create_bitmap_ex(8,resx,resy);
3928
3929 if(b)
3930 {
3931 blit(screen,b,0,0,0,0,resx,resy);
3932 save_bitmap(buf,b,RAMpal);
3933 destroy_bitmap(b);
3934 }
3935
3936 return D_O_K;
3937 }
3938
3939 int32_t onNonGUISnapshot()
3940 {
3941 PALETTE temppal;
3942 get_palette(temppal);
3943 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3944
3945 char buf[200];
3946 int32_t num=0;
3947
3948 do
3949 {
3950 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3951 }
3952 while(num<99999 && exists(buf));
3953
3954 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3955
3956 return D_O_K;
3957 }
3958
3959 int32_t onSnapshot()
3960 {
3961 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3962 {
3963 onGUISnapshot();
3964 }
3965 else
3966 {
3967 onNonGUISnapshot();
3968 }
3969
3970 return D_O_K;
3971 }
3972
3973 int32_t onSaveMapPic()
3974 {
3975 int32_t mapres2 = 0;
3976 char buf[200];
3977 int32_t num=0;
3978 mapscr tmpscr_b[2];
3979 mapscr tmpscr_c[6];
3980 BITMAP* _screen_draw_buffer = NULL;
3981 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3982 set_clip_state(_screen_draw_buffer,1);
3983
3984 for(int32_t i=0; i<6; ++i)
3985 {
3986 tmpscr_c[i] = tmpscr2[i];
3987 tmpscr2[i].zero_memory();
3988
3989 if(i>=2)
3990 {
3991 continue;
3992 }
3993
3994 tmpscr_b[i] = tmpscr[i];
3995 tmpscr[i].zero_memory();
3996 }
3997
3998 do
3999 {
4000 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4001 }
4002 while(num<99999 && exists(buf));
4003
4004 BITMAP* mappic = NULL;
4005
4006
4007 bool done=false, redraw=true;
4008
4009 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4010
4011 if(!mappic)
4012 {
4013 enter_sys_pal();
4014 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4015 exit_sys_pal();
4016 return D_O_K;;
4017 }
4018
4019 // draw the map
4020 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4021
4022 for(int32_t y=0; y<8; y++)
4023 {
4024 for(int32_t x=0; x<16; x++)
4025 {
4026 if(!displayOnMap(x, y))
4027 {
4028 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4029 }
4030 else
4031 {
4032 int32_t s = (y<<4) + x;
4033 loadscr2(1,s,-1);
4034
4035 for(int32_t i=0; i<6; i++)
4036 {
4037 if(tmpscr[1].layermap[i]<=0)
4038 continue;
4039
4040 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4041 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4042 {
4043 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4044
4045 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4046 }
4047 }
4048
4049 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4050
4051 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4052
4053 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4054 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4055
4056 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4057
4058 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4059 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4060 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4061 {
4062 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4063 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4064 }
4065 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4066
4067 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4068
4069 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4070 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4071 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4072 {
4073 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4074 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4075 }
4076 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4077 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4078
4079 }
4080
4081 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4082 }
4083 }
4084
4085 for(int32_t i=0; i<6; ++i)
4086 {
4087 tmpscr2[i]=tmpscr_c[i];
4088
4089 if(i>=2)
4090 {
4091 continue;
4092 }
4093
4094 tmpscr[i]=tmpscr_b[i];
4095 }
4096
4097 save_bitmap(buf,mappic,RAMpal);
4098 destroy_bitmap(mappic);
4099 destroy_bitmap(_screen_draw_buffer);
4100 return D_O_K;
4101 }
4102
4103 13 void f_Quit(int32_t type)
4104 {
4105
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(type==qQUIT && !Playing)
4106 return;
4107
4108 13 bool from_menu = is_sys_pal;
4109
4110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4111 {
4112 13 music_pause();
4113 13 pause_all_sfx();
4114 13 sys_mouse();
4115 13 }
4116 13 enter_sys_pal();
4117 13 clear_keybuf();
4118
4119
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (replay_is_active() && replay_get_version() <= 9)
4120 13 replay_poll();
4121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_is_replaying())
4122 13 replay_peek_quit();
4123
4124
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (!replay_is_replaying())
4125 switch(type)
4126 {
4127 case qQUIT:
4128 onQuit();
4129 break;
4130
4131 case qRESET:
4132 onReset();
4133 break;
4134
4135 case qEXIT:
4136 onExit();
4137 break;
4138 }
4139
4140
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Quit)
4141 {
4142 13 kill_sfx();
4143 13 music_stop();
4144 13 exit_sys_pal();
4145 13 update_hw_screen();
4146 13 }
4147 else
4148 {
4149 exit_sys_pal();
4150 if(!from_menu)
4151 {
4152 music_resume();
4153 resume_all_sfx();
4154 }
4155 }
4156
4157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4158 13 game_mouse();
4159 13 eat_buttons();
4160
4161 13 zc_readrawkey(KEY_ESC);
4162
4163 13 zc_readrawkey(KEY_ENTER);
4164 13 }
4165
4166 //----------------------------------------------------------------
4167
4168 int32_t onNoWalls()
4169 {
4170 cheats_enqueue(Cheat::Walls);
4171 return D_O_K;
4172 }
4173
4174 int32_t onIgnoreSideview()
4175 {
4176 cheats_enqueue(Cheat::IgnoreSideView);
4177 return D_O_K;
4178 }
4179
4180 8116376 int32_t input_idle(bool checkmouse)
4181 {
4182 static int32_t mx, my, mz, mb;
4183
4184
4/6
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127588 times.
✓ Branch 3 taken 5988788 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2127588 times.
10243964 if(keypressed() || zc_key_pressed() ||
4185
4/8
✓ Branch 0 taken 2127588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2127588 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2127588 times.
✗ Branch 7 not taken.
2127588 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4186 {
4187 5988788 idle_count = 0;
4188
4189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5988788 times.
5988788 if(active_count < MAX_ACTIVE)
4190 {
4191 5988788 ++active_count;
4192 5988788 }
4193 5988788 }
4194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127588 times.
2127588 else if(idle_count < MAX_IDLE)
4195 {
4196 2127588 ++idle_count;
4197 2127588 active_count = 0;
4198 2127588 }
4199
4200 8116376 mx = mouse_x;
4201 8116376 my = mouse_y;
4202 8116376 mz = mouse_z;
4203 8116376 mb = mouse_b;
4204
4205 8116376 return idle_count;
4206 }
4207
4208 int32_t onGoFast()
4209 {
4210 cheats_enqueue(Cheat::Fast);
4211 return D_O_K;
4212 }
4213
4214 int32_t onKillCheat()
4215 {
4216 cheats_enqueue(Cheat::Kill);
4217 return D_O_K;
4218 }
4219
4220 int32_t onSecretsCheat()
4221 {
4222 cheats_enqueue(Cheat::TrigSecrets);
4223 return D_O_K;
4224 }
4225 int32_t onSecretsCheatPerm()
4226 {
4227 cheats_enqueue(Cheat::TrigSecretsPerm);
4228 return D_O_K;
4229 }
4230
4231 int32_t onShowLayer0()
4232 {
4233 show_layer_0 = !show_layer_0;
4234 return D_O_K;
4235 }
4236 int32_t onShowLayer1()
4237 {
4238 show_layer_1 = !show_layer_1;
4239 return D_O_K;
4240 }
4241 int32_t onShowLayer2()
4242 {
4243 show_layer_2 = !show_layer_2;
4244 return D_O_K;
4245 }
4246 int32_t onShowLayer3()
4247 {
4248 show_layer_3 = !show_layer_3;
4249 return D_O_K;
4250 }
4251 int32_t onShowLayer4()
4252 {
4253 show_layer_4 = !show_layer_4;
4254 return D_O_K;
4255 }
4256 int32_t onShowLayer5()
4257 {
4258 show_layer_5 = !show_layer_5;
4259 return D_O_K;
4260 }
4261 int32_t onShowLayer6()
4262 {
4263 show_layer_6 = !show_layer_6;
4264 return D_O_K;
4265 }
4266 int32_t onShowLayerO()
4267 {
4268 show_layer_over=!show_layer_over;
4269 return D_O_K;
4270 }
4271 int32_t onShowLayerP()
4272 {
4273 show_layer_push=!show_layer_push;
4274 return D_O_K;
4275 }
4276 int32_t onShowLayerS()
4277 {
4278 show_sprites=!show_sprites;
4279 return D_O_K;
4280 }
4281 int32_t onShowLayerF()
4282 {
4283 show_ffcs=!show_ffcs;
4284 return D_O_K;
4285 }
4286 int32_t onShowLayerW()
4287 {
4288 show_walkflags=!show_walkflags;
4289 if(show_walkflags)
4290 show_effectflags = false;
4291 return D_O_K;
4292 }
4293 int32_t onShowLayerE()
4294 {
4295 show_effectflags=!show_effectflags;
4296 if(show_effectflags)
4297 show_walkflags = false;
4298 return D_O_K;
4299 }
4300 int32_t onShowFFScripts()
4301 {
4302 show_ff_scripts=!show_ff_scripts;
4303 return D_O_K;
4304 }
4305 int32_t onShowHitboxes()
4306 {
4307 show_hitboxes=!show_hitboxes;
4308 return D_O_K;
4309 }
4310 int32_t onShowInfoOpacity()
4311 {
4312 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4313 zc_set_config("zc","debug_info_opacity",info_opacity);
4314 return D_O_K;
4315 }
4316
4317 int32_t onLightSwitch()
4318 {
4319 cheats_enqueue(Cheat::Light);
4320 return D_O_K;
4321 }
4322
4323 int32_t onGoTo();
4324 int32_t onGoToComplete();
4325
4326 8116376 void syskeys()
4327 {
4328 8116376 update_system_keys();
4329
4330 int32_t oldtitle_version;
4331
4332
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(close_button_quit)
4333 {
4334 close_button_quit=false;
4335 f_Quit(qEXIT);
4336 }
4337
4338 8116376 poll_joystick();
4339
4340
2/10
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8116376 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8116376 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4341 {
4342 oldtitle_version=title_version;
4343 System();
4344 }
4345
4346 8116376 mouse_down=gui_mouse_b();
4347
4348
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(zc_read_system_key(KEY_F1))
4349 {
4350 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4351 {
4352 halt=!halt;
4353 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4354 }
4355 else
4356 {
4357 Throttlefps=!Throttlefps;
4358 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4359 logic_counter=0;
4360 }
4361 }
4362
4363 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4364 /*
4365 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4366 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4367 */
4368
4369
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(zc_read_system_key(KEY_F2))
4370 {
4371 ShowFPS=!ShowFPS;
4372 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4373 }
4374
4375
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8116376 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8116376 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4376
4377
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8116376 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8116376 if(zc_read_system_key(KEY_F4) && Playing)
4378 {
4379 Paused=true;
4380 Advance=true;
4381 }
4382
4383
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(zc_read_system_key(KEY_F6)) onTryQuit();
4384
4385 #ifndef ALLEGRO_MACOSX
4386
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4387
4388
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4389 #else
4390 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4391
4392 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4393 #endif
4394
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8116376 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8116376 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4395
4396
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if (zc_read_system_key(KEY_F12))
4397 {
4398 onSnapshot();
4399 }
4400
4401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8116376 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8116376 if(debug_enabled && zc_read_system_key(KEY_TAB))
4402 set_debug(!get_debug());
4403
4404
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(CheatModifierKeys())
4405 {
4406 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4407 {
4408 if(!bindable_cheat(c))
4409 continue;
4410 if(get_debug() || cheat >= cheat_lvl(c))
4411 {
4412 if(checkcheat(c))
4413 cheats_hit_bind(c);
4414 }
4415 }
4416 }
4417
4418
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(volkeys)
4419 {
4420 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4421
4422 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4423
4424 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4425
4426 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4427 }
4428
4429
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8116376 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8116376 if(!get_debug() || !SystemKeys || replay_is_replaying())
4430 8116376 goto bottom;
4431
4432 if(zc_readkey(KEY_D))
4433 {
4434 details = !details;
4435 rectfill(screen,0,0,319,7,BLACK);
4436 rectfill(screen,0,8,31,239,BLACK);
4437 rectfill(screen,288,8,319,239,BLACK);
4438 rectfill(screen,32,232,287,239,BLACK);
4439 }
4440
4441 if(zc_readkey(KEY_P)) Paused=!Paused;
4442
4443 //if(zc_readkey(KEY_P)) centerHero();
4444 if(zc_readkey(KEY_A))
4445 {
4446 Paused=true;
4447 Advance=true;
4448 }
4449
4450 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4451 #ifndef ALLEGRO_MACOSX
4452 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4453
4454 if(zc_readkey(KEY_F7))
4455 {
4456 Matrix(ss_speed, ss_density, 0);
4457 game_pal();
4458 }
4459 #else
4460 // The reason these are different on Mac in the first place is that
4461 // the OS doesn't let us use F9 and F10...
4462 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4463
4464 if(zc_readkey(KEY_F9))
4465 {
4466 Matrix(ss_speed, ss_density, 0);
4467 game_pal();
4468 }
4469 #endif
4470 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4471 {
4472 //change containers
4473 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4474 {
4475 //magic containers
4476 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4477 {
4478 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4479 }
4480 else
4481 {
4482 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4483 }
4484 }
4485 else
4486 {
4487 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4488 {
4489 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4490 }
4491 else
4492 {
4493 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4494 }
4495 }
4496 }
4497
4498 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4499 {
4500 //change containers
4501 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4502 {
4503 //magic containers
4504 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4505 {
4506 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4507 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4508 //heart containers
4509 }
4510 else
4511 {
4512 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4513 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4514 }
4515 }
4516 else
4517 {
4518 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4519 {
4520 game->set_magic(zc_max(game->get_magic()-1,0));
4521 }
4522 else
4523 {
4524 game->set_life(zc_max(game->get_life()-1,0));
4525 }
4526 }
4527 }
4528
4529 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4530
4531 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4532
4533 verifyBothWeapons();
4534
4535 bottom:
4536
4537
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(input_idle(true) > after_time())
4538 {
4539 Matrix(ss_speed, ss_density, 0);
4540 game_pal();
4541 }
4542 8116376 }
4543
4544 425514 void checkQuitKeys()
4545 {
4546 #ifndef ALLEGRO_MACOSX
4547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425514 times.
425514 if(key[KEY_F9]) f_Quit(qRESET);
4548
4549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425514 times.
425514 if(key[KEY_F10]) f_Quit(qEXIT);
4550 #else
4551 if(key[KEY_F7]) f_Quit(qRESET);
4552
4553 if(key[KEY_F8]) f_Quit(qEXIT);
4554 #endif
4555 425514 }
4556
4557 8116376 bool CheatModifierKeys()
4558 {
4559 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4560 // to trigger cheats.
4561
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if (replay_is_replaying())
4562 8116376 return false;
4563
4564 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4565 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4566 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4567 {
4568 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4569 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4570 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4571 {
4572 return true;
4573 }
4574 }
4575 return false;
4576 8116376 }
4577
4578 //99:05:54, for some reason?
4579 #define OLDMAXTIME 21405240
4580 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4581 #define MAXTIME 1944000000
4582
4583 8116459 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4584 {
4585
2/2
✓ Branch 0 taken 7822874 times.
✓ Branch 1 taken 293585 times.
8116459 if(zcmusic!=NULL)
4586 {
4587 293585 zcmusic_poll();
4588 293585 }
4589
4590 8116459 updatescr(allowwavy);
4591
4592 8116459 Advance=false;
4593
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8116459 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8116459 times.
8116459 while(Paused && !Advance && !Quit)
4594 {
4595 // have to call this, otherwise we'll get an infinite loop
4596 syskeys();
4597 if(allowF6Script)
4598 {
4599 FFCore.runF6Engine();
4600 }
4601 throttleFPS();
4602
4603 #ifdef _WIN32
4604
4605 if(use_dwm_flush)
4606 {
4607 do_DwmFlush();
4608 }
4609
4610 #endif
4611
4612 // to keep music playing
4613 if(zcmusic!=NULL)
4614 {
4615 zcmusic_poll();
4616 }
4617
4618 update_hw_screen();
4619 }
4620
4621
2/2
✓ Branch 0 taken 8116388 times.
✓ Branch 1 taken 71 times.
8116459 if(Quit)
4622 71 return;
4623
4624
3/4
✓ Branch 0 taken 7943369 times.
✓ Branch 1 taken 173019 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7943369 times.
8116388 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4625 7943369 game->change_time(1);
4626
4627
5/6
✓ Branch 0 taken 8116388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1512823 times.
✓ Branch 3 taken 6603565 times.
✓ Branch 4 taken 6689 times.
✓ Branch 5 taken 1506134 times.
8116388 if (replay_is_active() && replay_get_version() >= 11 && replay_get_version() < 16)
4628
2/2
✓ Branch 0 taken 27110412 times.
✓ Branch 1 taken 1506134 times.
28616546 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4629 28616546 down_control_states[i] = raw_control_state[i];
4630
4631
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8116390 times.
8116388 if (replay_is_active())
4632 {
4633
2/2
✓ Branch 0 taken 1270465 times.
✓ Branch 1 taken 6845925 times.
8116390 if (replay_get_version() >= 3)
4634 6845925 replay_poll();
4635
4636
6/6
✓ Branch 0 taken 6603555 times.
✓ Branch 1 taken 1512821 times.
✓ Branch 2 taken 3182903 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 3082368 times.
8116390 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4637 1613356 replay_peek_input();
4638 8116376 }
4639
4640 8116388 load_control_called_this_frame = false;
4641
4642 8116388 poll_keyboard();
4643 8116388 update_keys();
4644
4645 8116388 ++frame;
4646
4647
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8116376 times.
8116388 if (replay_is_replaying())
4648 8116376 replay_do_cheats();
4649 8116388 syskeys();
4650
4651 // The mouse variables can change from the mouse thread at anytime during a frame,
4652 // so save the result at the start so that replaying is consistent.
4653 8116388 script_mouse_x = gui_mouse_x();
4654 8116388 script_mouse_y = gui_mouse_y();
4655 8116388 script_mouse_z = mouse_z;
4656 8116388 script_mouse_b = mouse_b;
4657
4658 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4659 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4660 // approach here means it doesn't matter which call adds the cheat.
4661 8116388 cheats_execute_queued();
4662
4663
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8116376 times.
8116388 if (replay_is_replaying())
4664 8116376 replay_peek_quit();
4665
2/2
✓ Branch 0 taken 8116375 times.
✓ Branch 1 taken 13 times.
8116388 if (GameFlags & GAMEFLAG_TRYQUIT)
4666 13 replay_step_quit(0);
4667
2/2
✓ Branch 0 taken 2932 times.
✓ Branch 1 taken 8113456 times.
8116388 if(allowF6Script)
4668 8113456 FFCore.runF6Engine();
4669
2/2
✓ Branch 0 taken 8116159 times.
✓ Branch 1 taken 229 times.
8116388 if (Quit)
4670 229 replay_step_quit(Quit);
4671 // Someday... maybe install a Turbo button here?
4672 8116388 throttleFPS();
4673
4674 #ifdef _WIN32
4675
4676 if(use_dwm_flush)
4677 {
4678 do_DwmFlush();
4679 }
4680
4681 #endif
4682
4683 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4684
2/2
✓ Branch 0 taken 46694 times.
✓ Branch 1 taken 8069694 times.
8116388 if(sfxcleanup)
4685 8069694 sfx_cleanup();
4686 8116459 }
4687
4688 70 void zapout()
4689 {
4690 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4691 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4692
4693 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4694 70 script_drawing_commands.Clear();
4695
4696 // zap out
4697
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=1; i<=24; i++)
4698 {
4699 1680 draw_fuzzy(i);
4700 1680 advanceframe(true);
4701
4702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4703 {
4704 break;
4705 }
4706 1680 }
4707 70 }
4708
4709 70 void zapin()
4710 {
4711 70 FFCore.warpScriptCheck();
4712 70 draw_screen(tmpscr);
4713 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4714 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4715 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4716
4717 // zap out
4718 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4719
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=24; i>=1; i--)
4720 {
4721 1680 draw_fuzzy(i);
4722 1680 advanceframe(true);
4723
4724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4725 {
4726 break;
4727 }
4728 1680 }
4729 70 }
4730
4731
4732 38 void wavyout(bool showhero)
4733 {
4734 38 draw_screen(tmpscr, showhero);
4735 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4736
4737 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4738 38 clear_to_color(wavebuf,0);
4739 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4740
4741 static PALETTE wavepal;
4742
4743 int32_t ofs;
4744 38 int32_t amplitude=8;
4745
4746 38 int32_t wavelength=4;
4747 38 double palpos=0, palstep=4, palstop=126;
4748
4749 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4750
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4751 {
4752
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4753 {
4754 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4755 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4756 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4757 408576 }
4758
4759 1596 palpos+=palstep;
4760
4761
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4762 {
4763 1596 hw_palette = &wavepal;
4764 1596 update_hw_pal = true;
4765 1596 }
4766 else
4767 {
4768 hw_palette = &RAMpal;
4769 update_hw_pal = true;
4770 }
4771
4772
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4773 {
4774
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4775 {
4776 68640768 ofs=0;
4777
4778
4/4
✓ Branch 0 taken 33503232 times.
✓ Branch 1 taken 35137536 times.
✓ Branch 2 taken 16751616 times.
✓ Branch 3 taken 16751616 times.
68640768 if((j<i)&&(j&1))
4779 {
4780 16751616 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4781 16751616 }
4782
4783 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4784 68640768 }
4785 268128 }
4786
4787 1596 advanceframe(true);
4788
4789 // animate_combos();
4790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4791 break;
4792 1596 }
4793
4794 38 destroy_bitmap(wavebuf);
4795 38 }
4796
4797 38 void wavyin()
4798 {
4799 38 draw_screen(tmpscr);
4800 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4801
4802 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4803 38 clear_to_color(wavebuf,0);
4804 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4805
4806 static PALETTE wavepal;
4807
4808 //Breaks dark rooms.
4809 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4810 /*
4811 loadfullpal();
4812 loadlvlpal(DMaps[currdmap].color);
4813 ringcolor(false);
4814 */
4815 38 refreshpal=false;
4816 int32_t ofs;
4817 38 int32_t amplitude=8;
4818 38 int32_t wavelength=4;
4819 38 double palpos=168, palstep=4, palstop=126;
4820
4821 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4822
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4823 {
4824
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4825 {
4826 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4827 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4828 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4829 408576 }
4830
4831 1596 palpos-=palstep;
4832
4833
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4834 {
4835 1596 hw_palette = &wavepal;
4836 1596 update_hw_pal = true;
4837 1596 }
4838 else
4839 {
4840 hw_palette = &RAMpal;
4841 update_hw_pal = true;
4842 }
4843
4844
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4845 {
4846
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4847 {
4848 68640768 ofs=0;
4849
4850
4/4
✓ Branch 0 taken 34728960 times.
✓ Branch 1 taken 33911808 times.
✓ Branch 2 taken 17568768 times.
✓ Branch 3 taken 17160192 times.
68640768 if((j<(167-i))&&(j&1))
4851 {
4852 17160192 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4853 17160192 }
4854
4855 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4856 68640768 }
4857 268128 }
4858
4859 1596 advanceframe(true);
4860 // animate_combos();
4861
4862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4863 break;
4864 1596 }
4865
4866 38 destroy_bitmap(wavebuf);
4867 38 }
4868
4869 1921 void blackscr(int32_t fcnt,bool showsubscr)
4870 {
4871 1921 reset_pal_cycling();
4872 1921 script_drawing_commands.Clear();
4873
4874 1921 FFCore.warpScriptCheck();
4875 1921 bool showtime = game->should_show_time();
4876
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 57560 times.
59481 while(fcnt>0)
4877 {
4878 57560 clear_bitmap(framebuf);
4879
4880
2/2
✓ Branch 0 taken 19710 times.
✓ Branch 1 taken 37850 times.
57560 if(showsubscr)
4881 {
4882 37850 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4883
3/4
✓ Branch 0 taken 37850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 37100 times.
37850 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4884 {
4885 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4886 750 }
4887 37850 }
4888
4889 57560 advanceframe(true);
4890
4891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57560 times.
57560 if(Quit)
4892 break;
4893
4894 57560 --fcnt;
4895 }
4896 1921 }
4897
4898 728 void openscreen(int32_t shape)
4899 {
4900 728 reset_pal_cycling();
4901 728 black_opening_count=0;
4902
4903
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 629 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
728 if(COOLSCROLL || shape>-1)
4904 {
4905 629 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4906 629 return;
4907 }
4908 else
4909 {
4910 99 Hero.setDontDraw(true);
4911 99 show_subscreen_dmap_dots=false;
4912 99 show_subscreen_numbers=false;
4913 // show_subscreen_items=false;
4914 99 show_subscreen_life=false;
4915 }
4916
4917 99 int32_t x=128;
4918
4919 99 FFCore.warpScriptCheck();
4920
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 7920 times.
8019 for(int32_t i=0; i<80; i++)
4921 {
4922 7920 draw_screen(tmpscr);
4923 //? draw_screen already draws the subscreen -DD
4924 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4925 7920 x=128-(((i*128/80)/8)*8);
4926
4927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(x>0)
4928 {
4929 7920 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4930 7920 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4931 7920 }
4932
4933 7920 advanceframe(true);
4934
4935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(Quit)
4936 {
4937 break;
4938 }
4939 7920 }
4940
4941 99 Hero.setDontDraw(false);
4942 99 show_subscreen_items=true;
4943 99 show_subscreen_dmap_dots=true;
4944 728 }
4945
4946 void closescreen(int32_t shape)
4947 {
4948 reset_pal_cycling();
4949 black_opening_count=0;
4950
4951 if(COOLSCROLL || shape>-1)
4952 {
4953 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4954 return;
4955 }
4956 else
4957 {
4958 Hero.setDontDraw(true);
4959 show_subscreen_dmap_dots=false;
4960 show_subscreen_numbers=false;
4961 // show_subscreen_items=false;
4962 show_subscreen_life=false;
4963 }
4964
4965 int32_t x=128;
4966
4967 FFCore.warpScriptCheck();
4968 for(int32_t i=79; i>=0; --i)
4969 {
4970 draw_screen(tmpscr);
4971 //? draw_screen already draws the subscreen -DD
4972 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4973 x=128-(((i*128/80)/8)*8);
4974
4975 if(x>0)
4976 {
4977 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4978 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4979 }
4980
4981 advanceframe(true);
4982
4983 if(Quit)
4984 {
4985 break;
4986 }
4987 }
4988
4989 Hero.setDontDraw(false);
4990 show_subscreen_items=true;
4991 show_subscreen_dmap_dots=true;
4992 }
4993
4994 179 int32_t TriforceCount()
4995 {
4996 179 int32_t c=0;
4997
4998
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
4999
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5000 1044 ++c;
5001
5002 179 return c;
5003 }
5004
5005 int32_t onCustomGame()
5006 {
5007 int32_t file = getsaveslot();
5008
5009 if(file < 0)
5010 return D_O_K;
5011
5012 bool ret = (custom_game(file)!=0);
5013 return ret ? D_CLOSE : D_O_K;
5014 }
5015
5016 int32_t onContinue()
5017 {
5018 return D_CLOSE;
5019 }
5020
5021 int32_t onEsc() // Unused?? -L
5022 {
5023 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5024 }
5025
5026 int32_t onVsync()
5027 {
5028 Throttlefps = !Throttlefps;
5029 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5030 return D_O_K;
5031 }
5032
5033 int32_t onWinPosSave()
5034 {
5035 SaveWinPos = !SaveWinPos;
5036 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5037 return D_O_K;
5038 }
5039 int32_t onIntegerScaling()
5040 {
5041 scaleForceInteger = !scaleForceInteger;
5042 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5043 return D_O_K;
5044 }
5045 int32_t onStretchGame()
5046 {
5047 stretchGame = !stretchGame;
5048 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5049 return D_O_K;
5050 }
5051
5052 int32_t onClickToFreeze()
5053 {
5054 ClickToFreeze = !ClickToFreeze;
5055 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5056 return D_O_K;
5057 }
5058
5059 int32_t OnSaveZCConfig()
5060 {
5061 if(jwin_alert3(
5062 "Save Configuration",
5063 "Are you sure that you wish to save your present configuration settings?",
5064 "This will overwrite your prior settings!",
5065 NULL,
5066 "&Yes",
5067 "&No",
5068 NULL,
5069 'y',
5070 'n',
5071 0,
5072 get_zc_font(font_lfont)) == 1)
5073 {
5074 save_game_configs();
5075 return D_O_K;
5076 }
5077 else return D_O_K;
5078 }
5079
5080 int32_t OnnClearQuestDir()
5081 {
5082 if(jwin_alert3(
5083 "Clear Current Directory Cache",
5084 "Are you sure that you wish to clear the current cached directory?",
5085 "This will default the current directory to the ROOT for this instance of ZC Player!",
5086 NULL,
5087 "&Yes",
5088 "&No",
5089 NULL,
5090 'y',
5091 'n',
5092 0,
5093 get_zc_font(font_lfont)) == 1)
5094 {
5095 zc_set_config("zeldadx","win_qst_dir","");
5096 flush_config_file();
5097 strcpy(qstdir,"");
5098 #ifdef __EMSCRIPTEN__
5099 em_sync_fs();
5100 #endif
5101 return D_O_K;
5102 }
5103 else return D_O_K;
5104 }
5105
5106
5107 int32_t onConsoleZASM()
5108 {
5109 if ( !zasm_debugger )
5110 {
5111 AlertDialog("WARNING: ZASM Debugger",
5112 "Enabling this will open the ZASM Debugger Console"
5113 "\nThis will likely grind ZC to a halt with lag."
5114 "\nTo make any use of this, it is suggested that you read"
5115 "\nthe documentation for 'void Breakpoint(char[] string);'"
5116 " in 'ZScript_Additions.txt'"
5117 "\nThis is not recommended for normal users,"
5118 " and is only intended for ZC developers,"
5119 "\nor quest developers coding directly in ZASM"
5120 "\nAre you sure that you wish to open the ZASM Debugger?",
5121 [&](bool ret,bool)
5122 {
5123 if(ret)
5124 {
5125 FFCore.ZASMPrint(true);
5126 }
5127 }).show();
5128 return D_O_K;
5129 }
5130 else
5131 {
5132 FFCore.ZASMPrint(false);
5133 return D_O_K;
5134 }
5135 }
5136
5137
5138 int32_t onConsoleZScript()
5139 {
5140 if ( !zscript_debugger )
5141 {
5142 AlertDialog("ZScript Debugger",
5143 "Enabling this will open the ZScript Debugger Console"
5144 "\nThis will display any messages logged by scripts,"
5145 " including script errors."
5146 "\nAre you sure that you wish to open the ZScript Debugger?",
5147 [&](bool ret,bool)
5148 {
5149 if(ret)
5150 {
5151 FFCore.ZScriptConsole(true);
5152 }
5153 }).show();
5154 return D_O_K;
5155 }
5156 else
5157 {
5158 FFCore.ZScriptConsole(false);
5159 return D_O_K;
5160 }
5161 }
5162
5163 int32_t onClrConsoleOnReload()
5164 {
5165 clearConsoleOnReload = !clearConsoleOnReload;
5166 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5167 return D_O_K;
5168 }
5169 int32_t onClrConsoleOnLoad()
5170 {
5171 clearConsoleOnLoad = !clearConsoleOnLoad;
5172 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5173 return D_O_K;
5174 }
5175
5176
5177 int32_t onFrameSkip()
5178 {
5179 FrameSkip = !FrameSkip;
5180 return D_O_K;
5181 }
5182
5183 int32_t onSaveDragResize()
5184 {
5185 SaveDragResize = !SaveDragResize;
5186 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5187 return D_O_K;
5188 }
5189
5190 int32_t onDragAspect()
5191 {
5192 DragAspect = !DragAspect;
5193 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5194 return D_O_K;
5195 }
5196
5197 int32_t onTransLayers()
5198 {
5199 TransLayers = !TransLayers;
5200 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5201 return D_O_K;
5202 }
5203
5204 int32_t onNESquit()
5205 {
5206 NESquit = !NESquit;
5207 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5208 return D_O_K;
5209 }
5210
5211 int32_t onVolKeys()
5212 {
5213 volkeys = !volkeys;
5214 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5215 return D_O_K;
5216 }
5217
5218 int32_t onShowFPS()
5219 {
5220 ShowFPS = !ShowFPS;
5221 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5222 return D_O_K;
5223 }
5224
5225 957732368 bool is_Fkey(int32_t k)
5226 {
5227
2/2
✓ Branch 0 taken 97396512 times.
✓ Branch 1 taken 860335856 times.
957732368 switch(k)
5228 {
5229 case KEY_F1:
5230 case KEY_F2:
5231 case KEY_F3:
5232 case KEY_F4:
5233 case KEY_F5:
5234 case KEY_F6:
5235 case KEY_F7:
5236 case KEY_F8:
5237 case KEY_F9:
5238 case KEY_F10:
5239 case KEY_F11:
5240 case KEY_F12:
5241 97396512 return true;
5242 }
5243
5244 860335856 return false;
5245 957732368 }
5246
5247 void kb_getkey(DIALOG *d);
5248
5249 //Used by all keyboard key settings dialogues.
5250 void kb_clearjoystick(DIALOG *d)
5251 {
5252 d->flags|=D_SELECTED;
5253
5254 jwin_button_proc(MSG_DRAW,d,0);
5255 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5256 // text_mode(vc(11));
5257 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5258 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5259
5260 update_hw_screen(true);
5261
5262 clear_keybuf();
5263 int32_t k = next_press_key();
5264 clear_keybuf();
5265
5266 //shnarf
5267 //47=f1
5268 //59=esc
5269 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5270 // *((int32_t*)d->dp3) = k;
5271 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5272
5273
5274 d->flags&=~D_SELECTED;
5275 }
5276
5277 //Clears key to 0.
5278 //Used by all keyboard key settings dialogues.
5279 void kb_clearkey(DIALOG *d);
5280
5281 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5282 {
5283 switch(msg)
5284 {
5285 case MSG_KEY:
5286 case MSG_CLICK:
5287
5288 kb_clearjoystick(d);
5289
5290 while(gui_mouse_b())
5291 {
5292 clear_keybuf();
5293 rest(1);
5294 }
5295
5296 return D_REDRAW;
5297 }
5298
5299 return jwin_button_proc(msg,d,c);
5300 }
5301
5302 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5303 //Only used in keyboard settings dialogues to clear keys.
5304 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5305
5306 void j_getbtn(DIALOG *d)
5307 {
5308 d->flags|=D_SELECTED;
5309 jwin_button_proc(MSG_DRAW,d,0);
5310 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5311 // text_mode(vc(11));
5312 int32_t y = gui_bmp->h/2 - 12;
5313 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5314 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5315 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5316
5317 update_hw_screen(true);
5318
5319 int32_t b = next_press_btn();
5320
5321 if(b>=0)
5322 *((int32_t*)d->dp3) = b;
5323
5324 d->flags&=~D_SELECTED;
5325
5326 if (player)
5327 player->joy_on = TRUE;
5328 }
5329
5330 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5331 {
5332 switch(msg)
5333 {
5334 case MSG_KEY:
5335 case MSG_CLICK:
5336
5337 j_getbtn(d);
5338
5339 while(gui_mouse_b()) {
5340 rest(1);
5341 clear_keybuf();
5342 }
5343
5344 return D_REDRAW;
5345 }
5346
5347 return jwin_button_proc(msg,d,c);
5348 }
5349
5350 //shnarf
5351 extern const char *key_str[];
5352 std::string get_keystr(int key);
5353
5354 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5355 //extern int32_t zcmusic_bufsz;
5356
5357 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5358 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5359
5360 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5361 {
5362 //these are here to bypass compiler warnings about unused arguments
5363 c=c;
5364
5365 if(msg==MSG_DRAW)
5366 {
5367 switch(d->w)
5368 {
5369 case 0:
5370 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5371 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5372 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5373 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5374 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5375 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5376 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5377 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5378 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5379 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5380 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5381 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5382 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5383 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5384 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5385 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5386 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5387 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5388 break;
5389
5390 case 1:
5391 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5392 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5393 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5394 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5395 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5396 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5397 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5398 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5399 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5400 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5401 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5402 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5403 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5404 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5405 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5406 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5407 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5408 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5409 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5410 break;
5411
5412 case 2:
5413 sprintf(str_a," %3d",midi_volume);
5414 sprintf(str_b," %3d",digi_volume);
5415 sprintf(str_l," %3d",emusic_volume);
5416 sprintf(str_m," %3dKB",zcmusic_bufsz);
5417 sprintf(str_r," %3d",sfx_volume);
5418 strcpy(str_s,pan_str[pan_style]);
5419 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5420 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5421 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5422 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5423 break;
5424 }
5425 }
5426
5427 return D_O_K;
5428 }
5429
5430 int32_t set_vol(void *dp3, int32_t d2)
5431 {
5432 switch(((int32_t*)dp3)[0])
5433 {
5434 case 0:
5435 midi_volume = zc_min(d2<<3,255);
5436 break;
5437
5438 case 1:
5439 digi_volume = zc_min(d2<<3,255);
5440 break;
5441
5442 case 2:
5443 emusic_volume = zc_min(d2<<3,255);
5444 break;
5445
5446 case 3:
5447 sfx_volume = zc_min(d2<<3,255);
5448 break;
5449 }
5450
5451 // text_mode(vc(11));
5452 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5453 return D_O_K;
5454 }
5455
5456 int32_t set_pan(void *dp3, int32_t d2)
5457 {
5458 pan_style = vbound(d2,0,3);
5459 // text_mode(vc(11));
5460 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5461 return D_O_K;
5462 }
5463
5464 int32_t set_buf(void *dp3, int32_t d2)
5465 {
5466 // text_mode(vc(11));
5467 zcmusic_bufsz = d2 + 1;
5468 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5469 return D_O_K;
5470 }
5471
5472 static int32_t gamepad_btn_list[] =
5473 {
5474 6,
5475 7,8,9,10,11,12,13,14,15,16,17,
5476 18,19,20,21,22,23,24,25,26,27,28,
5477 29,30,31,32,33,34,35,36,37,38,39,
5478 -1
5479 };
5480
5481 static int32_t gamepad_dirs_list[] =
5482 {
5483 40,41,42,43,
5484 44,45,46,47,
5485 48,49,50,51,
5486 52,53,54,55,
5487 56,
5488 -1
5489 };
5490
5491 static TABPANEL gamepad_tabs[] =
5492 {
5493 // (text)
5494 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5495 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5496 { NULL, 0, NULL, 0, NULL }
5497 };
5498
5499 static DIALOG gamepad_dlg[] =
5500 {
5501 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5502 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5503 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5504 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5505 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5506 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5507 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5508 // 6
5509 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5510 // 7
5511 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5512 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5513 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5514 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5515 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5516 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5517 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5518 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5519 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5520 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5521 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5522 // 18
5523 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5524 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5525 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5526 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5527 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5528 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5529 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5530 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5531 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5532 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5533 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5534 // 29
5535 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5536 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5537 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5538 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5539 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5540 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5541 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5542 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5543 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5544 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5545 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5546 // 40
5547 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5548 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5549 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5550 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5551 // 44
5552 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5553 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5554 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5555 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5556 // 48
5557 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5558 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5559 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5560 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5561 // 52
5562 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5563 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5564 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5565 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5566 // 56
5567 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5568 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5569 };
5570
5571 static int32_t keyboard_keys_list[] =
5572 {
5573 6,7,8,9,10,
5574 11,12,13,14,15,16,17,18,19,20,
5575 21,22,23,24,25,26,27,28,29,30,
5576 31,32,33,34,35,36,37,38,39,40,
5577 -1
5578 };
5579
5580 static int32_t keyboard_dirs_list[] =
5581 {
5582 41,42,43,44,
5583 45,46,47,48,
5584 49,50,51,52,
5585 53,54,55,56,
5586 -1
5587 };
5588
5589 static int32_t keyboard_mods_list[] =
5590 {
5591 57,58,59,60,
5592 61,62,63,64,
5593 65,66,67,68,
5594 69,70,71,72,
5595 -1
5596 };
5597
5598 static TABPANEL keyboard_control_tabs[] =
5599 {
5600 // (text)
5601 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5602 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5603 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5604 { NULL, 0, NULL, 0, NULL }
5605 };
5606
5607 static DIALOG keyboard_control_dlg[] =
5608 {
5609 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5610 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5611 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5612 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5613 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5614 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5615 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5616 // Keys
5617 // 6
5618 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5619 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5620 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5621 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5622 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5623 // 11
5624 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5625 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5626 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5627 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5628 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5629 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5630 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5631 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5632 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5633 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5634 // 21
5635 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5636 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5637 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5638 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5639 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5640 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5641 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5642 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5643 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5644 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5645 // 31
5646 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5647 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5648 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5649 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5650 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5651 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5652 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5653 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5654 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5655 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5656 // Dirs
5657 // 41
5658 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5659 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5660 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5661 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5662 // 45
5663 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5664 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5665 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5666 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5667 // 49
5668 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5669 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5670 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5671 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5672 // 53
5673 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5674 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5675 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5676 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5677 // Mods
5678 // 57
5679 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5680 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5681 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5682 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5683 // 61
5684 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5685 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5686 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5687 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5688 // 65
5689 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5690 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5691 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5692 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5693 // 69
5694 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5695 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5696 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5697 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5698 // 73
5699 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5700 };
5701
5702 /*
5703 int32_t midi_dp[3] = {0,147,104};
5704 int32_t digi_dp[3] = {1,147,120};
5705 int32_t pan_dp[3] = {0,147,136};
5706 int32_t buf_dp[3] = {0,147,152};
5707 */
5708 int32_t midi_dp[3] = {0,0,0};
5709 int32_t digi_dp[3] = {1,0,0};
5710 int32_t emus_dp[3] = {2,0,0};
5711 int32_t buf_dp[3] = {0,0,0};
5712 int32_t sfx_dp[3] = {3,0,0};
5713 int32_t pan_dp[3] = {0,0,0};
5714
5715 static DIALOG sound_dlg[] =
5716 {
5717 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5718 38 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5719 38 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5720 38 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5721 38 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5722 38 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5723 38 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5724 38 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5725 38 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5726 38 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5727 38 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5728 // 10
5729 38 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5730 38 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5731 38 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5732 38 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5733 38 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5734 38 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5735 38 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5736 38 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5737 38 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5738 38 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5739 //20
5740 38 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5741 38 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5742 38 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5743 38 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5744 38 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5745 38 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5746 38 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5747 38 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5748 38 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5749 38 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5750 //30
5751 38 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5752 38 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5753 38 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5754 38 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5755 };
5756
5757 char zc_builddate[80];
5758 char zc_aboutstr[80];
5759
5760 static DIALOG about_dlg[] =
5761 {
5762 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5763 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5764 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5765 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5766 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5767 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5768 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5769 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5770 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5771 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5772 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5773 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5774 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5775 };
5776
5777
5778 static DIALOG quest_dlg[] =
5779 {
5780 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5781 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5782 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5783 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5784 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5785 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5786 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5787 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5788 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5789 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5790 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5791 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5792 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5793 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5794 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5795 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5796 };
5797
5798 static DIALOG triforce_dlg[] =
5799 {
5800 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5801 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5802 // 1
5803 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5804 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5805 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5806 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5807 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5808 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5809 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5810 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5811 // 9
5812 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5813 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5814 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5815 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5816 };
5817
5818 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5819 {
5820 go();
5821 int32_t ret=0;
5822 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5823 comeback();
5824 return ret != 0;
5825 }
5826
5827
5828 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5829 {
5830 if(def!=modulepath)
5831 strcpy(modulepath,def);
5832
5833 if(!usefilename)
5834 {
5835 int32_t i=(int32_t)strlen(modulepath);
5836
5837 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5838 modulepath[i--]=0;
5839 }
5840
5841 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5842 int32_t ret=0;
5843 int32_t sel=0;
5844
5845 if(list==NULL)
5846 {
5847 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5848 }
5849 else
5850 {
5851 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5852 }
5853
5854 return ret!=0;
5855 }
5856
5857 //The Dialogue that loads a ZMOD Module File
5858 int32_t zc_load_zmod_module_file()
5859 {
5860 if ( Playing )
5861 {
5862 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5863 return -1;
5864 }
5865 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5866 return D_CLOSE;
5867
5868 FILE *tempmodule = fopen(modulepath,"r");
5869
5870 if(tempmodule == NULL)
5871 {
5872 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5873 return -1;
5874 }
5875
5876
5877 //Set the module path:
5878 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5879 strcpy(moduledata.module_name, modulepath);
5880 al_trace("New Module Path is: %s \n", moduledata.module_name);
5881 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5882 zcm.init(true); //Load the module values.
5883 moduledata.refresh_title_screen = 1;
5884 // refresh_select_screen = 1;
5885 build_biic_list();
5886 return D_O_K;
5887 }
5888
5889 static DIALOG module_info_dlg[] =
5890 {
5891 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5892
5893
5894 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5895 //1
5896 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5897 //2
5898 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5899 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5900 //4
5901 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5902 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5903 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5904 //7
5905
5906 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5907 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5908 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5909 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5910 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5911 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5912 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5913 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5914 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5915
5916 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5917 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5918 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5919 };
5920
5921 void about_zcplayer_module(const char *prompt,int32_t initialval)
5922 {
5923
5924 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5925 if ( moduledata.moduletitle[0] != 0 )
5926 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5927
5928 if ( moduledata.moduleauthor[0] != 0 )
5929 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5930
5931 if ( moduledata.moduleinfo0[0] != 0 )
5932 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
5933 if ( moduledata.moduleinfo1[0] != 0 )
5934 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
5935 if ( moduledata.moduleinfo2[0] != 0 )
5936 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
5937 if ( moduledata.moduleinfo3[0] != 0 )
5938 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
5939 if ( moduledata.moduleinfo4[0] != 0 )
5940 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
5941
5942 char module_date[255];
5943 memset(module_date, 0, sizeof(module_date));
5944 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
5945 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
5946
5947
5948
5949 char module_vers[255];
5950 memset(module_vers, 0, sizeof(module_vers));
5951 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
5952
5953
5954 //sprintf(tilecount,"%d",1);
5955
5956 char module_build[255];
5957 memset(module_build, 0, sizeof(module_build));
5958 if ( moduledata.modbeta )
5959 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
5960 else
5961 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
5962
5963 module_info_dlg[12].dp = (char*)module_date;
5964 module_info_dlg[13].dp = (char*)module_vers;
5965 module_info_dlg[14].dp = (char*)module_build;
5966
5967 large_dialog(module_info_dlg);
5968
5969 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
5970 jwin_center_dialog(module_info_dlg);
5971
5972
5973 }
5974
5975 int32_t onAbout_ZCP_Module()
5976 {
5977 about_zcplayer_module("About Module (.zmod)", 0);
5978 return D_O_K;
5979 }
5980
5981 //New Modules Menu for 2.55+
5982 static MENU zcmodule_menu[] =
5983 {
5984 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
5985 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
5986
5987 { NULL, NULL, NULL, 0, NULL }
5988 };
5989
5990 int32_t onToggleRecordingNewSaves()
5991 {
5992 if (zc_get_config("zeldadx", "replay_new_saves", false))
5993 {
5994 zc_set_config("zeldadx", "replay_new_saves", false);
5995 }
5996 else
5997 {
5998 zc_set_config("zeldadx", "replay_new_saves", true);
5999 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6000 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6001 }
6002 return D_O_K;
6003 }
6004
6005 int32_t onToggleSnapshotAllFrames()
6006 {
6007 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6008 return D_O_K;
6009 }
6010
6011 int32_t onStopReplayOrRecord()
6012 {
6013 if (replay_is_replaying())
6014 {
6015 replay_quit();
6016 }
6017 else if (replay_get_mode() == ReplayMode::Record)
6018 {
6019 if (!replay_get_meta_bool("test_mode"))
6020 {
6021 jwin_alert("Recording", "You cannot stop recording a save file.",
6022 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6023 return D_CLOSE;
6024 }
6025
6026 if (jwin_alert("Stop Recording",
6027 "Save replay to disk and stop recording?",
6028 "This will stop the recording.",
6029 NULL,
6030 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6031 return D_CLOSE;
6032
6033 replay_save();
6034 replay_stop();
6035 }
6036 return D_O_K;
6037 }
6038
6039 static int32_t handle_on_load_replay(ReplayMode mode)
6040 {
6041 if (Playing)
6042 {
6043 if (jwin_alert("Replay - Warning!",
6044 "Loading a replay will exit the current game.",
6045 "All unsaved progress will be lost.",
6046 "Do you wish to continue?",
6047 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6048 return D_CLOSE;
6049 }
6050
6051 std::string mode_string = replay_mode_to_string(mode);
6052 mode_string[0] = std::toupper(mode_string[0]);
6053
6054 std::string line_1 = "Select a replay file to play back.";
6055 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6056 std::string line_3 = "You can stop the replay and take over manually any time.";
6057 if (mode == ReplayMode::Update)
6058 {
6059 line_1 = "Select a replay file to update.";
6060 line_2 = "WARNING: be sure to back up the zplay file";
6061 line_3 = "and verify that the updated replay works as expected!";
6062 }
6063
6064 if (jwin_alert(mode_string.c_str(),
6065 line_1.c_str(),
6066 line_2.c_str(),
6067 line_3.c_str(),
6068 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6069 {
6070 char replay_path[2048];
6071 strcpy(replay_path, "replays/");
6072 if (jwin_file_select_ex(
6073 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6074 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6075 return D_CLOSE;
6076
6077 replay_quit();
6078 load_replay_file_deferred(mode, replay_path);
6079 Quit = qRESET;
6080 return D_CLOSE;
6081 }
6082 return D_O_K;
6083 }
6084
6085 int32_t onLoadReplay()
6086 {
6087 return handle_on_load_replay(ReplayMode::Replay);
6088 }
6089
6090 int32_t onLoadReplayAssert()
6091 {
6092 return handle_on_load_replay(ReplayMode::Assert);
6093 }
6094
6095 int32_t onLoadReplayUpdate()
6096 {
6097 return handle_on_load_replay(ReplayMode::Update);
6098 }
6099
6100 int32_t onSaveReplay()
6101 {
6102 if (replay_get_mode() == ReplayMode::Record)
6103 {
6104 if (!replay_get_meta_bool("test_mode"))
6105 {
6106 if (jwin_alert("Save Replay",
6107 "This will save a copy of the replay up to this point.",
6108 "The official replay file will be untouched.",
6109 "Do you wish to continue?",
6110 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6111 return D_CLOSE;
6112
6113 char replay_path[2048];
6114 strcpy(replay_path, replay_get_replay_path().string().c_str());
6115 if (jwin_file_select_ex(
6116 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6117 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6118 return D_CLOSE;
6119
6120 if (fileexists(replay_path))
6121 {
6122 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6123 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6124 return D_CLOSE;
6125 }
6126
6127 replay_save(replay_path);
6128 }
6129 else
6130 {
6131 replay_save();
6132 }
6133 }
6134 return D_O_K;
6135 }
6136
6137 static MENU replay_menu[] =
6138 {
6139 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6140 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6141 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6142 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6143 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6144 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6145 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6146
6147 { NULL, NULL, NULL, 0, NULL }
6148 };
6149
6150 static DIALOG credits_dlg[] =
6151 {
6152 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6153 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6154 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6155 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6156 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6157 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6158 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6159 };
6160
6161 38 static ListData dmap_list(dmaplist, &font);
6162
6163 static DIALOG goto_dlg[] =
6164 {
6165 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6166 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6167 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6168 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6169 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6170 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6171 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6172 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6173 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6174 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6175 };
6176
6177 int32_t onGoTo()
6178 {
6179 bool music = false;
6180 music = music;
6181 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6182
6183 goto_dlg[0].dp2=get_zc_font(font_lfont);
6184 goto_dlg[4].d2=cheat_goto_dmap;
6185 goto_dlg[6].dp=cheat_goto_screen_str;
6186
6187 clear_keybuf();
6188
6189 large_dialog(goto_dlg);
6190
6191 if(zc_popup_dialog(goto_dlg,4)==1)
6192 {
6193 // dmap, screen
6194 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6195 };
6196
6197 return D_O_K;
6198 }
6199
6200 int32_t onGoToComplete()
6201 {
6202 if(!Playing)
6203 {
6204 return D_O_K;
6205 }
6206
6207 enter_sys_pal();
6208 music_pause();
6209 pause_all_sfx();
6210 onGoTo();
6211 eat_buttons();
6212
6213 zc_readrawkey(KEY_ESC);
6214
6215 exit_sys_pal();
6216 music_resume();
6217 resume_all_sfx();
6218 return D_O_K;
6219 }
6220
6221 int32_t onCredits()
6222 {
6223 go();
6224
6225 BITMAP *win = create_bitmap_ex(8,222,110);
6226
6227 if(!win)
6228 return D_O_K;
6229
6230 int32_t c=0;
6231 int32_t l=0;
6232 int32_t ol=-1;
6233 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6234 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6235 PALETTE tmppal;
6236
6237 rti_gui.transparency_index = 1;
6238
6239 clear_to_color(win, rti_gui.transparency_index);
6240 draw_rle_sprite(win,rle,0,0);
6241 credits_dlg[0].dp2=get_zc_font(font_lfont);
6242 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6243 credits_dlg[2].dp = win;
6244
6245 zc_set_palette_range(black_palette,0,127,false);
6246
6247 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6248
6249 BITMAP* old_screen = screen;
6250 BITMAP* gui_bmp = zc_get_gui_bmp();
6251 ASSERT(gui_bmp);
6252 clear_to_color(gui_bmp, rti_gui.transparency_index);
6253 screen = gui_bmp;
6254
6255 while(update_dialog(p))
6256 {
6257 throttleFPS();
6258 ++c;
6259 l = zc_max((c>>1)-30,0);
6260
6261 if(l > rle->h)
6262 l = c = 0;
6263
6264 if(l > rle->h - 112)
6265 l = rle->h - 112;
6266
6267 clear_bitmap(win);
6268 draw_rle_sprite(win,rle,0,0-l);
6269
6270 if(c<=64)
6271 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6272
6273 zc_set_palette_range(tmppal,0,127,false);
6274
6275 if(l!=ol)
6276 {
6277 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6278 SCRFIX();
6279 ol=l;
6280 }
6281
6282 update_hw_screen();
6283 }
6284
6285 screen = old_screen;
6286 system_pal(true);
6287 sys_mouse();
6288
6289 shutdown_dialog(p);
6290 destroy_bitmap(win);
6291 //comeback();
6292
6293 rti_gui.transparency_index = 0;
6294 clear_to_color(gui_bmp, rti_gui.transparency_index);
6295
6296 return D_O_K;
6297 }
6298
6299 const char *midilist(int32_t index, int32_t *list_size)
6300 {
6301 if(index<0)
6302 {
6303 *list_size=0;
6304
6305 for(int32_t i=0; i<MAXMIDIS; i++)
6306 if(tunes[i].data)
6307 ++(*list_size);
6308
6309 return NULL;
6310 }
6311
6312 int32_t i=0,m=0;
6313
6314 while(m<=index && i<=MAXMIDIS)
6315 {
6316 if(tunes[i].data)
6317 ++m;
6318
6319 ++i;
6320 }
6321
6322 --i;
6323
6324 if(i==MAXMIDIS && m<index)
6325 return "(null)";
6326
6327 return tunes[i].title;
6328 }
6329
6330 /* ------- MIDI info stuff -------- */
6331
6332 char *text;
6333 midi_info *zmi;
6334 bool dialog_running;
6335 bool listening;
6336
6337 void get_info(int32_t index);
6338
6339 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6340 {
6341 int32_t d2 = d->d2;
6342 int32_t ret = jwin_droplist_proc(msg,d,c);
6343
6344 if(d2!=d->d2)
6345 {
6346 get_info(d->d2);
6347 }
6348
6349 return ret;
6350 }
6351
6352 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6353 {
6354 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6355
6356 int32_t ret = jwin_button_proc(msg,d,c);
6357
6358 if(ret == D_CLOSE)
6359 {
6360 // get current midi index
6361 int32_t index = (d+(d->d1))->d2;
6362 int32_t i=0, m=0;
6363
6364 while(m<=index && i<=MAXMIDIS)
6365 {
6366 if(tunes[i].data)
6367 ++m;
6368
6369 ++i;
6370 }
6371
6372 --i;
6373 jukebox(i);
6374 listening = true;
6375 ret = D_O_K;
6376 }
6377
6378 return ret;
6379 }
6380
6381 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6382 {
6383 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6384
6385 int32_t ret = jwin_button_proc(msg,d,c);
6386
6387 if(ret == D_CLOSE)
6388 {
6389 // get current midi index
6390 int32_t index = (d+(d->d1))->d2;
6391 int32_t i=0, m=0;
6392
6393 while(m<=index && i<=MAXMIDIS)
6394 {
6395 if(tunes[i].data)
6396 ++m;
6397
6398 ++i;
6399 }
6400
6401 --i;
6402
6403 // get file name
6404
6405 int32_t sel=0;
6406 //struct ffblk f;
6407 char title[40] = "Save MIDI: ";
6408 char fname[2048];
6409 memset(fname,0,2048);
6410 static EXT_LIST list[] =
6411 {
6412 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6413 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6414 { NULL, NULL }
6415 };
6416
6417 strcpy(title+11, tunes[i].title);
6418 title[39] = '\0';
6419
6420 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6421 goto done;
6422
6423 if(exists(fname))
6424 {
6425 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6426 goto done;
6427 }
6428
6429 // save midi i
6430
6431 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6432 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6433
6434 done:
6435 chop_path(fname);
6436 ret = D_REDRAW;
6437 }
6438
6439 return ret;
6440 }
6441
6442 38 static ListData midi_list(midilist, &font);
6443
6444 static DIALOG midi_dlg[] =
6445 {
6446 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6447 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6448 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6449 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6450 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6451 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6452 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6453 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6454 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6455 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6456 };
6457
6458 void get_info(int32_t index)
6459 {
6460 int32_t i=0, m=0;
6461
6462 while(m<=index && i<=MAXMIDIS)
6463 {
6464 if(tunes[i].data)
6465 ++m;
6466
6467 ++i;
6468 }
6469
6470 --i;
6471
6472 if(i==MAXMIDIS && m<index)
6473 strcpy(text,"(null)");
6474 else
6475 {
6476 get_midi_info((MIDI*)tunes[i].data,zmi);
6477 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6478 }
6479
6480 midi_dlg[0].dp2=get_zc_font(font_lfont);
6481 midi_dlg[3].dp = text;
6482 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6483 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6484
6485 if(dialog_running)
6486 {
6487 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6488 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6489 }
6490 }
6491
6492 int32_t onMIDICredits()
6493 {
6494 text = (char*)malloc(4096);
6495 zmi = (midi_info*)malloc(sizeof(midi_info));
6496
6497 if(!text || !zmi)
6498 {
6499 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6500 return D_O_K;
6501 }
6502
6503 bool do_pause_midi = midi_pos >= 0 && currmidi;
6504 auto restore_midi = currmidi;
6505 if(do_pause_midi)
6506 {
6507 paused_midi_pos = midi_pos;
6508 stop_midi();
6509 midi_paused=true;
6510 midi_suspended = midissuspHALTED;
6511 }
6512
6513 midi_dlg[0].dp2=get_zc_font(font_lfont);
6514 midi_dlg[2].d1 = 0;
6515 midi_dlg[2].d2 = 0;
6516 midi_dlg[4].flags = D_EXIT;
6517 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6518
6519 listening = false;
6520 dialog_running=false;
6521 get_info(0);
6522
6523 dialog_running=true;
6524
6525 large_dialog(midi_dlg);
6526
6527 zc_popup_dialog(midi_dlg,0);
6528 dialog_running=false;
6529
6530 if(listening)
6531 music_stop();
6532
6533 if(do_pause_midi)
6534 {
6535 midi_suspended = midissuspRESUME;
6536 currmidi = restore_midi;
6537 midi_pos = paused_midi_pos;
6538 }
6539
6540 if(text) free(text);
6541 if(zmi) free(zmi);
6542 return D_O_K;
6543 }
6544
6545 int32_t onAbout()
6546 {
6547 char buf1[80]={0};
6548 std::ostringstream oss;
6549 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6550 oss << buf1 << '\n';
6551 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6552 oss << buf1 << '\n';
6553 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6554 oss << buf1 << '\n';
6555 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6556 oss << buf1 << '\n';
6557 sprintf(buf1, "Tag: %s", getReleaseTag());
6558 oss << buf1 << '\n';
6559
6560 InfoDialog("About ZC", oss.str()).show();
6561 return D_O_K;
6562 }
6563
6564 int32_t onQuest()
6565 {
6566 char fname[100];
6567 strcpy(fname, get_filename(qstpath));
6568 quest_dlg[0].dp2=get_zc_font(font_lfont);
6569 quest_dlg[1].dp = fname;
6570
6571 if(QHeader.quest_number==0)
6572 sprintf(str_a,"Custom");
6573 else
6574 sprintf(str_a,"%d",QHeader.quest_number);
6575
6576 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6577
6578 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6579 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6580
6581 large_dialog(quest_dlg);
6582
6583 zc_popup_dialog(quest_dlg, 0);
6584 return D_O_K;
6585 }
6586
6587 void call_vidmode_dlg();
6588 int32_t onVidMode()
6589 {
6590 call_vidmode_dlg();
6591 return D_O_K;
6592 }
6593
6594 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6595 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6596 //Added an extra statement, so that if the key is cleared to 0, the cleared
6597 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6598
6599 void load_ukeys(int32_t* arr)
6600 {
6601 arr[ukey_a] = Akey;
6602 arr[ukey_b] = Bkey;
6603 arr[ukey_s] = Skey;
6604 arr[ukey_l] = Lkey;
6605 arr[ukey_r] = Rkey;
6606 arr[ukey_p] = Pkey;
6607 arr[ukey_ex1] = Exkey1;
6608 arr[ukey_ex2] = Exkey2;
6609 arr[ukey_ex3] = Exkey3;
6610 arr[ukey_ex4] = Exkey4;
6611 arr[ukey_du] = DUkey;
6612 arr[ukey_dd] = DDkey;
6613 arr[ukey_dl] = DLkey;
6614 arr[ukey_dr] = DRkey;
6615 arr[ukey_mod1a] = cheat_modifier_keys[0];
6616 arr[ukey_mod1b] = cheat_modifier_keys[1];
6617 arr[ukey_mod2a] = cheat_modifier_keys[2];
6618 arr[ukey_mod2b] = cheat_modifier_keys[3];
6619 };
6620
6621 static const char* ukey_names[] = {
6622 "A", "B", "Start", "L", "R", "Map",
6623 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6624 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6625 "Cheat Mod R1", "Cheat Mod R2",
6626 };
6627 std::string get_ukey_name(int32_t k)
6628 {
6629 if (k < num_ukey) return ukey_names[k];
6630 return "";
6631 }
6632
6633 int32_t onKeyboard()
6634 {
6635 int32_t a = Akey;
6636 int32_t b = Bkey;
6637 int32_t s = Skey;
6638 int32_t l = Lkey;
6639 int32_t r = Rkey;
6640 int32_t p = Pkey;
6641 int32_t ex1 = Exkey1;
6642 int32_t ex2 = Exkey2;
6643 int32_t ex3 = Exkey3;
6644 int32_t ex4 = Exkey4;
6645 int32_t du = DUkey;
6646 int32_t dd = DDkey;
6647 int32_t dl = DLkey;
6648 int32_t dr = DRkey;
6649 int32_t mod1a = cheat_modifier_keys[0];
6650 int32_t mod1b = cheat_modifier_keys[1];
6651 int32_t mod2a = cheat_modifier_keys[2];
6652 int32_t mod2b = cheat_modifier_keys[3];
6653 bool done=false;
6654 int32_t ret;
6655
6656 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6657
6658 large_dialog(keyboard_control_dlg);
6659
6660 while(!done)
6661 {
6662 ret = zc_popup_dialog(keyboard_control_dlg,3);
6663
6664 if(ret==3) // OK
6665 {
6666 int32_t ukeys[num_ukey];
6667 load_ukeys(ukeys);
6668 std::vector<std::string> uniqueError;
6669 for(int32_t q = 0; q < num_ukey; ++q)
6670 {
6671 for(int32_t p = q+1; p < num_ukey; ++p)
6672 {
6673 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6674 {
6675 char buf[64];
6676 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6677 std::string str(buf);
6678 uniqueError.push_back(str);
6679 }
6680 }
6681 }
6682 if(uniqueError.size() == 0)
6683 {
6684 done = true;
6685 save_control_configs(true);
6686 }
6687 else
6688 {
6689 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6690 box_out("Cannot have duplicate keybinds!"); box_eol();
6691 for(std::vector<std::string>::iterator it = uniqueError.begin();
6692 it != uniqueError.end(); ++it)
6693 {
6694 box_out((*it).c_str()); box_eol();
6695 }
6696 box_end(true);
6697 }
6698 }
6699 else // Cancel
6700 {
6701 Akey = a;
6702 Bkey = b;
6703 Skey = s;
6704 Lkey = l;
6705 Rkey = r;
6706 Pkey = p;
6707 Exkey1 = ex1;
6708 Exkey2 = ex2;
6709 Exkey3 = ex3;
6710 Exkey4 = ex4;
6711 DUkey = du;
6712 DDkey = dd;
6713 DLkey = dl;
6714 DRkey = dr;
6715 cheat_modifier_keys[0] = mod1a;
6716 cheat_modifier_keys[1] = mod1b;
6717 cheat_modifier_keys[2] = mod2a;
6718 cheat_modifier_keys[3] = mod2b;
6719
6720 done=true;
6721 }
6722
6723 rest(1);
6724 }
6725
6726 return D_O_K;
6727 }
6728
6729 int32_t onGamepad()
6730 {
6731 int32_t a = Abtn;
6732 int32_t b = Bbtn;
6733 int32_t s = Sbtn;
6734 int32_t l = Lbtn;
6735 int32_t r = Rbtn;
6736 int32_t m = Mbtn;
6737 int32_t p = Pbtn;
6738 int32_t ex1 = Exbtn1;
6739 int32_t ex2 = Exbtn2;
6740 int32_t ex3 = Exbtn3;
6741 int32_t ex4 = Exbtn4;
6742 int32_t up = DUbtn;
6743 int32_t down = DDbtn;
6744 int32_t left = DLbtn;
6745 int32_t right = DRbtn;
6746
6747 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6748 if(analog_movement)
6749 gamepad_dlg[56].flags|=D_SELECTED;
6750 else
6751 gamepad_dlg[56].flags&=~D_SELECTED;
6752
6753 large_dialog(gamepad_dlg);
6754
6755 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6756
6757 if(ret == 4) //OK
6758 {
6759 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6760 save_control_configs(false);
6761 }
6762 else //Cancel
6763 {
6764 Abtn = a;
6765 Bbtn = b;
6766 Sbtn = s;
6767 Lbtn = l;
6768 Rbtn = r;
6769 Mbtn = m;
6770 Pbtn = p;
6771 Exbtn1 = ex1;
6772 Exbtn2 = ex2;
6773 Exbtn3 = ex3;
6774 Exbtn4 = ex4;
6775 DUbtn = up;
6776 DDbtn = down;
6777 DLbtn = left;
6778 DRbtn = right;
6779 }
6780
6781 return D_O_K;
6782 }
6783
6784 int32_t onCheatKeys()
6785 {
6786 int32_t oldcheats[Cheat::Last][2];
6787 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6788
6789 bool done=false;
6790
6791 while(!done)
6792 {
6793 bool confirm = false;
6794 CheatKeysDialog(&confirm).show();
6795 if(confirm) // OK
6796 {
6797 std::vector<std::string> uniqueError;
6798 char buf[512];
6799 for(size_t q = 1; q < Cheat::Last; ++q)
6800 {
6801 if(cheatkeys[q][1] && !cheatkeys[q][0])
6802 {
6803 cheatkeys[q][0] = cheatkeys[q][1];
6804 cheatkeys[q][1] = 0;
6805 }
6806 }
6807 for(size_t q = 1; q < Cheat::Last; ++q)
6808 {
6809 if(!bindable_cheat((Cheat)q)) continue;
6810 for(size_t p = q+1; p < Cheat::Last; ++p)
6811 {
6812 if(!bindable_cheat((Cheat)p)) continue;
6813 for(size_t q2 = 0; q2 <= 1; ++q2)
6814 for(size_t p2 = 0; p2 <= 1; ++p2)
6815 {
6816 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6817 {
6818 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6819 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6820 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6821 get_keystr(cheatkeys[q][q2])));
6822 }
6823 }
6824 }
6825 }
6826 if(uniqueError.size() == 0)
6827 {
6828 done = true;
6829 save_cheatkeys();
6830 }
6831 else
6832 {
6833 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6834 box_out("Cannot have duplicate keybinds!"); box_eol();
6835 for(std::vector<std::string>::iterator it = uniqueError.begin();
6836 it != uniqueError.end(); ++it)
6837 {
6838 box_out((*it).c_str()); box_eol();
6839 }
6840 box_end(true);
6841 }
6842 }
6843 else // Cancel
6844 {
6845 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6846 done=true;
6847 }
6848 rest(1);
6849 }
6850
6851 return D_O_K;
6852 }
6853
6854 int32_t onSound()
6855 {
6856 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6857 {
6858 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6859 }
6860 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6861 {
6862 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6863 }
6864 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6865 {
6866 emusic_volume = (int32_t)FFCore.usr_music_volume;
6867 }
6868 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
6869 {
6870 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6871 }
6872 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6873 {
6874 pan_style = (int32_t)FFCore.usr_panstyle;
6875 }
6876
6877 int32_t m = midi_volume;
6878 int32_t d = digi_volume;
6879 int32_t e = emusic_volume;
6880 int32_t b = zcmusic_bufsz;
6881 int32_t s = sfx_volume;
6882 int32_t p = pan_style;
6883 pan_style = vbound(pan_style,0,3);
6884
6885 sound_dlg[0].dp2=get_zc_font(font_lfont);
6886
6887 large_dialog(sound_dlg);
6888
6889 midi_dp[1] = sound_dlg[6].x;
6890 midi_dp[2] = sound_dlg[6].y;
6891 digi_dp[1] = sound_dlg[7].x;
6892 digi_dp[2] = sound_dlg[7].y;
6893 emus_dp[1] = sound_dlg[8].x;
6894 emus_dp[2] = sound_dlg[8].y;
6895 buf_dp[1] = sound_dlg[9].x;
6896 buf_dp[2] = sound_dlg[9].y;
6897 sfx_dp[1] = sound_dlg[10].x;
6898 sfx_dp[2] = sound_dlg[10].y;
6899 pan_dp[1] = sound_dlg[11].x;
6900 pan_dp[2] = sound_dlg[11].y;
6901 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6902 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6903 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6904 sound_dlg[18].d2 = zcmusic_bufsz;
6905 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6906 sound_dlg[20].d2 = pan_style;
6907
6908 int32_t ret = zc_popup_dialog(sound_dlg,1);
6909
6910 if(ret==2)
6911 {
6912 master_volume(digi_volume,midi_volume);
6913
6914 for(int32_t i=0; i<WAV_COUNT; ++i)
6915 {
6916 //allegro assertion fails when passing in -1 as voice -DD
6917 if(sfx_voice[i] > 0)
6918 voice_set_volume(sfx_voice[i], sfx_volume);
6919 }
6920 zc_set_config(sfx_sect,"digi",digi_volume);
6921 zc_set_config(sfx_sect,"midi",midi_volume);
6922 zc_set_config(sfx_sect,"sfx",sfx_volume);
6923 zc_set_config(sfx_sect,"emusic",emusic_volume);
6924 zc_set_config(sfx_sect,"pan",pan_style);
6925 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6926 }
6927 else
6928 {
6929 midi_volume = m;
6930 digi_volume = d;
6931 emusic_volume = e;
6932 zcmusic_bufsz = b;
6933 sfx_volume = s;
6934 pan_style = p;
6935 }
6936
6937 return D_O_K;
6938 }
6939
6940 int32_t queding(char const* s1, char const* s2, char const* s3)
6941 {
6942 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6943 }
6944
6945 int32_t onQuit()
6946 {
6947 if(Playing)
6948 {
6949 int32_t ret=0;
6950
6951 if(get_bit(quest_rules, qr_NOCONTINUE))
6952 {
6953 if(standalone_mode)
6954 {
6955 ret=queding("End current game?",
6956 "The continue screen is disabled; the game",
6957 "will be reloaded from the last save.");
6958 }
6959 else
6960 {
6961 ret=queding("End current game?",
6962 "The continue screen is disabled. You will",
6963 "be returned to the file select screen.");
6964 }
6965 }
6966 else
6967 ret=queding("End current game?",NULL,NULL);
6968
6969 if(ret==1)
6970 {
6971 disableClickToFreeze=false;
6972 Quit=qQUIT;
6973
6974 // Trying to evade a door repair charge?
6975 if(repaircharge)
6976 {
6977 game->change_drupy(-repaircharge);
6978 repaircharge=0;
6979 }
6980
6981 return D_CLOSE;
6982 }
6983 }
6984
6985 return D_O_K;
6986 }
6987
6988 int32_t onTryQuitMenu()
6989 {
6990 return onTryQuit(true);
6991 }
6992
6993 int32_t onTryQuit(bool inMenu)
6994 {
6995 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
6996 {
6997 if(active_cutscene.can_f6())
6998 {
6999 if(get_bit(quest_rules,qr_OLD_F6))
7000 {
7001 if(inMenu) onQuit();
7002 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7003 }
7004 else
7005 {
7006 disableClickToFreeze=false;
7007 GameFlags |= GAMEFLAG_TRYQUIT;
7008 }
7009 return D_CLOSE;
7010 }
7011 else active_cutscene.error();
7012 }
7013
7014 return D_O_K;
7015 }
7016
7017 int32_t onReset()
7018 {
7019 if(queding(" Reset system? ",NULL,NULL)==1)
7020 {
7021 disableClickToFreeze=false;
7022 Quit=qRESET;
7023 replay_quit();
7024 return D_CLOSE;
7025 }
7026
7027 return D_O_K;
7028 }
7029
7030 int32_t onExit()
7031 {
7032 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7033 {
7034 Quit=qEXIT;
7035 return D_CLOSE;
7036 }
7037
7038 return D_O_K;
7039 }
7040
7041 int32_t onTitle_NES()
7042 {
7043 title_version=0;
7044 zc_set_config(cfg_sect,"title",title_version);
7045 return D_O_K;
7046 }
7047 int32_t onTitle_DX()
7048 {
7049 title_version=1;
7050 zc_set_config(cfg_sect,"title",title_version);
7051 return D_O_K;
7052 }
7053 int32_t onTitle_25()
7054 {
7055 title_version=2;
7056 zc_set_config(cfg_sect,"title",title_version);
7057 return D_O_K;
7058 }
7059
7060 int32_t onDebug()
7061 {
7062 if(debug_enabled)
7063 set_debug(!get_debug());
7064 return D_O_K;
7065 }
7066
7067 int32_t onHeartBeep()
7068 {
7069 heart_beep=!heart_beep;
7070 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7071 return D_O_K;
7072 }
7073
7074 int32_t onSaveIndicator()
7075 {
7076 use_save_indicator = use_save_indicator ? 0 : 1;
7077 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7078 return D_O_K;
7079 }
7080
7081 int32_t onEpilepsy()
7082 {
7083 if(jwin_alert3(
7084 "Epilepsy Flash Reduction",
7085 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7086 "Disabling this will restore standard flash and wavy behaviour.",
7087 "Proceed?",
7088 "&Yes",
7089 "&No",
7090 NULL,
7091 'y',
7092 'n',
7093 0,
7094 get_zc_font(font_lfont)) == 1)
7095 {
7096 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7097 zc_set_config("zeldadx","checked_epilepsy",1);
7098 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7099 }
7100 return D_O_K;
7101 }
7102
7103 int32_t onTriforce()
7104 {
7105 for(int32_t i=0; i<MAXINITTABS; ++i)
7106 {
7107 init_tabs[i].flags&=~D_SELECTED;
7108 }
7109
7110 init_tabs[3].flags=D_SELECTED;
7111 return onCheatConsole();
7112 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7113 for(int32_t i=1; i<=8; i++)
7114 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7115
7116 if(zc_popup_dialog (triforce_dlg,-1)==9)
7117 {
7118 for(int32_t i=1; i<=8; i++)
7119 {
7120 game->lvlitems[i] &= ~liTRIFORCE;
7121 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7122 }
7123 }
7124 return D_O_K;*/
7125 }
7126
7127 bool rc = false;
7128 /*
7129 int32_t onEquipment()
7130 {
7131 for (int32_t i=0; i<MAXINITTABS; ++i)
7132 {
7133 init_tabs[i].flags&=~D_SELECTED;
7134 }
7135 init_tabs[0].flags=D_SELECTED;
7136 return onCheatConsole();
7137 }
7138 */
7139
7140 int32_t onItems()
7141 {
7142 for(int32_t i=0; i<MAXINITTABS; ++i)
7143 {
7144 init_tabs[i].flags&=~D_SELECTED;
7145 }
7146
7147 init_tabs[1].flags=D_SELECTED;
7148 return onCheatConsole();
7149 }
7150
7151 static DIALOG getnum_dlg[] =
7152 {
7153 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7154 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7155 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7156 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7157 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7158 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7159 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7160 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7161 };
7162
7163 int32_t getnumber(const char *prompt,int32_t initialval)
7164 {
7165 char buf[20];
7166 sprintf(buf,"%d",initialval);
7167 getnum_dlg[0].dp=(void *)prompt;
7168 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7169 getnum_dlg[2].dp=buf;
7170
7171 large_dialog(getnum_dlg);
7172
7173 if(zc_popup_dialog(getnum_dlg,2)==3)
7174 return atoi(buf);
7175
7176 return initialval;
7177 }
7178
7179 int32_t onLife()
7180 {
7181 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7182 cheats_enqueue(Cheat::Life, value);
7183 return D_O_K;
7184 }
7185
7186 int32_t onHeartC()
7187 {
7188 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7189 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7190 cheats_enqueue(Cheat::MaxLife, max_life);
7191 cheats_enqueue(Cheat::Life, life);
7192 return D_O_K;
7193 }
7194
7195 int32_t onMagicC()
7196 {
7197 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7198 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7199 cheats_enqueue(Cheat::MaxMagic, max_magic);
7200 cheats_enqueue(Cheat::Magic, magic);
7201 return D_O_K;
7202 }
7203
7204 int32_t onRupies()
7205 {
7206 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7207 cheats_enqueue(Cheat::Rupies, value);
7208 return D_O_K;
7209 }
7210
7211 int32_t onMaxBombs()
7212 {
7213 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7214 cheats_enqueue(Cheat::MaxBombs, value);
7215 cheats_enqueue(Cheat::Bombs, value);
7216 return D_O_K;
7217 }
7218
7219 int32_t onRefillLife()
7220 {
7221 cheats_enqueue(Cheat::Life, game->get_maxlife());
7222 return D_O_K;
7223 }
7224 int32_t onRefillMagic()
7225 {
7226 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7227 return D_O_K;
7228 }
7229 int32_t onClock()
7230 {
7231 cheats_enqueue(Cheat::Clock);
7232 return D_O_K;
7233 }
7234
7235 int32_t onQstPath()
7236 {
7237 char path[2048];
7238
7239 chop_path(qstdir);
7240 strcpy(path,qstdir);
7241
7242 go();
7243
7244 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7245 {
7246 chop_path(path);
7247 fix_filename_case(path);
7248 fix_filename_slashes(path);
7249 strcpy(qstdir,path);
7250 strcpy(qstpath,qstdir);
7251 }
7252
7253 comeback();
7254 return D_O_K;
7255 }
7256
7257 #include "dialog/cheat_dialog.h"
7258 int32_t onCheat()
7259 {
7260 call_setcheat_dialog();
7261 game->set_cheat(maxcheat);
7262 if(cheat) game->did_cheat(true);
7263 return D_O_K;
7264 }
7265
7266 int32_t onCheatRupies()
7267 {
7268 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7269 return D_O_K;
7270 }
7271
7272 int32_t onCheatArrows()
7273 {
7274 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7275 return D_O_K;
7276 }
7277
7278 int32_t onCheatBombs()
7279 {
7280 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7281 return D_O_K;
7282 }
7283
7284 // *** screen saver
7285
7286 8116376 int32_t after_time()
7287 {
7288
1/2
✓ Branch 0 taken 8116376 times.
✗ Branch 1 not taken.
8116376 if(ss_enable == 0)
7289 return INT_MAX;
7290
7291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116376 times.
8116376 if(ss_after <= 0)
7292 return 5 * 60;
7293
7294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116376 times.
8116376 if(ss_after <= 3)
7295 return ss_after * 15 * 60;
7296
7297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116376 times.
8116376 if(ss_after <= 13)
7298 return (ss_after - 3) * 60 * 60;
7299
7300 8116376 return MAX_IDLE + 1;
7301 8116376 }
7302
7303 static const char *after_str[15] =
7304 {
7305 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7306 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7307 "Never"
7308 };
7309
7310 const char *after_list(int32_t index, int32_t *list_size)
7311 {
7312 if(index < 0)
7313 {
7314 *list_size = 15;
7315 return NULL;
7316 }
7317
7318 return after_str[index];
7319 }
7320
7321 38 static ListData after__list(after_list, &font);
7322
7323 static DIALOG scrsaver_dlg[] =
7324 {
7325 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7326 38 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7327 38 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7328 38 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7329 38 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7330 38 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7331 38 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7332 38 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7333 38 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7334 38 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7335 38 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7336 38 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7337 38 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7338 38 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7339 };
7340
7341 int32_t onScreenSaver()
7342 {
7343 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7344 int32_t oldcfgs[3];
7345 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7346 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7347 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7348
7349 large_dialog(scrsaver_dlg);
7350
7351 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7352
7353 if(ret == 8 || ret == 9)
7354 {
7355 ss_after = scrsaver_dlg[5].d1;
7356 ss_speed = scrsaver_dlg[6].d2;
7357 ss_density = scrsaver_dlg[7].d2;
7358 if(oldcfgs[0] != ss_after)
7359 zc_set_config(cfg_sect,"ss_after",ss_after);
7360 if(oldcfgs[1] != ss_speed)
7361 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7362 if(oldcfgs[2] != ss_density)
7363 zc_set_config(cfg_sect,"ss_density",ss_density);
7364 }
7365
7366 if(ret == 9)
7367 // preview Screen Saver
7368 {
7369 clear_keybuf();
7370 Matrix(ss_speed, ss_density, 30);
7371 system_pal();
7372 sys_mouse();
7373 }
7374
7375 return D_O_K;
7376 }
7377
7378 /***** Menus *****/
7379
7380 static MENU game_menu[] =
7381 {
7382 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7383 { (char *)"", NULL, NULL, 0, NULL },
7384 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7385 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7386 { (char *)"", NULL, NULL, 0, NULL },
7387 #ifdef __EMSCRIPTEN__
7388 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7389 #elif defined(ALLEGRO_MACOSX)
7390 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7391 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7392 #else
7393 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7394 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7395 #endif
7396 { NULL, NULL, NULL, 0, NULL }
7397 };
7398
7399 static MENU title_menu[] =
7400 {
7401 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7402 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7403 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7404 { NULL, NULL, NULL, 0, NULL }
7405 };
7406
7407 static MENU snapshot_format_menu[] =
7408 {
7409 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7410 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7411 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7412 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7413 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7414 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7415 { NULL, NULL, NULL, 0, NULL }
7416 };
7417
7418 static MENU controls_menu[] =
7419 {
7420 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7421 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7422 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7423 { NULL, NULL, NULL, 0, NULL }
7424 };
7425
7426 static MENU name_entry_mode_menu[] =
7427 {
7428 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7429 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7430 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7431 { NULL, NULL, NULL, 0, NULL }
7432 };
7433
7434 static void set_controls_menu_active()
7435 {
7436
7437 }
7438
7439 static MENU window_menu[] =
7440 {
7441 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7442 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7443 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7444 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7445 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7446 { NULL, NULL, NULL, 0, NULL }
7447 };
7448 static MENU options_menu[] =
7449 {
7450 { "&Title Screen", NULL, title_menu, 0, NULL },
7451 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7452 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7453 { "&Window Settings", NULL, window_menu, 0, NULL },
7454 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7455 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7456 { NULL, NULL, NULL, 0, NULL }
7457 };
7458 static MENU settings_menu[] =
7459 {
7460 { "&Sound...", onSound, NULL, 0, NULL },
7461 { "C&ontrols", NULL, controls_menu, 0, NULL },
7462 { "", NULL, NULL, 0, NULL },
7463 { "Options", NULL, options_menu, 0, NULL },
7464 { "", NULL, NULL, 0, NULL },
7465 //
7466 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7467 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7468 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7469 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7470 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7471 //
7472 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7473 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7474 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7475 { "", NULL, NULL, 0, NULL },
7476 { "Debu&g", onDebug, NULL, 0, NULL },
7477 //
7478 { NULL, NULL, NULL, 0, NULL }
7479 };
7480
7481
7482 static MENU misc_menu[] =
7483 {
7484 { (char *)"&About...", onAbout, NULL, 0, NULL },
7485 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7486 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7487 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7488 { (char *)"", NULL, NULL, 0, NULL },
7489 //5
7490 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7491 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7492 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7493 { (char *)"", NULL, NULL, 0, NULL },
7494 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7495 //10
7496 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7497 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7498 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7499 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7500 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7501 //15
7502 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7503 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7504 { NULL, NULL, NULL, 0, NULL }
7505 };
7506
7507 static MENU refill_menu[] =
7508 {
7509 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7510 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7511 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7512 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7513 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7514 { NULL, NULL, NULL, 0, NULL }
7515 };
7516
7517 static MENU show_menu[] =
7518 {
7519 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7520 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7521 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7522 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7523 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7524 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7525 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7526 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7527 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7528 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7529 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7530 { (char *)"", NULL, NULL, 0, NULL },
7531 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7532 { (char *)"", NULL, NULL, 0, NULL },
7533 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7534 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7535 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7536 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7537 { NULL, NULL, NULL, 0, NULL }
7538 };
7539
7540 static MENU cheat_menu[] =
7541 {
7542 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7543 { (char *)"", NULL, NULL, 0, NULL },
7544 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7545 { (char *)"", NULL, NULL, 0, NULL },
7546 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7547 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7548 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7549 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7550 { (char *)"", NULL, NULL, 0, NULL },
7551 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7552 { (char *)"", NULL, NULL, 0, NULL },
7553 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7554 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7555 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7556 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7557 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7558 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7559 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7560 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7561 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7562 { NULL, NULL, NULL, 0, NULL }
7563 };
7564
7565 #if DEVLEVEL > 0
7566 int32_t devLogging();
7567 int32_t devDebug();
7568 int32_t devTimestmp();
7569 #if DEVLEVEL > 1
7570 int32_t setCheat();
7571 #endif //DEVLEVEL > 1
7572 enum
7573 {
7574 dv_log,
7575 // dv_dbg,
7576 dv_tmpstmp,
7577 #if DEVLEVEL > 1
7578 dv_nil,
7579 dv_setcheat,
7580 #endif //DEVLEVEL > 1
7581 dv_max
7582 };
7583 static MENU dev_menu[] =
7584 {
7585 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7586 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7587 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7588 #if DEVLEVEL > 1
7589 { (char *)"", NULL, NULL, 0, NULL },
7590 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7591 #endif //DEVLEVEL > 1
7592 { NULL, NULL, NULL, 0, NULL }
7593 };
7594 int32_t devLogging()
7595 {
7596 dev_logging = !dev_logging;
7597 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7598 return D_O_K;
7599 }
7600 // int32_t devDebug()
7601 // {
7602 // dev_debug = !dev_debug;
7603 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7604 // return D_O_K;
7605 // }
7606 int32_t devTimestmp()
7607 {
7608 dev_timestmp = !dev_timestmp;
7609 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7610 return D_O_K;
7611 }
7612 #if DEVLEVEL > 1
7613 int32_t setCheat()
7614 {
7615 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7616 return D_O_K;
7617 }
7618 #endif //DEVLEVEL > 1
7619 #endif //DEVLEVEL > 0
7620
7621 MENU the_player_menu[] =
7622 {
7623 { (char *)"&Game", NULL, game_menu, 0, NULL },
7624 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7625 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7626 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7627 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7628 #if DEVLEVEL > 0
7629 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7630 #endif
7631 { NULL, NULL, NULL, 0, NULL }
7632 };
7633 int32_t onMIDIPatch()
7634 {
7635 if(jwin_alert3(
7636 "Toggle Windows MIDI Fix",
7637 "This action will change whether ZC Player auto-restarts a MIDI at its",
7638 "last index if you move ZC Player out of focus, then back into focus.",
7639 "Proceed?",
7640 "&Yes",
7641 "&No",
7642 NULL,
7643 'y',
7644 'n',
7645 0,
7646 get_zc_font(font_lfont)) == 1)
7647 {
7648 midi_patch_fix = midi_patch_fix ? 0 : 1;
7649 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7650 }
7651 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7652 return D_O_K;
7653 }
7654
7655 int32_t onKeyboardEntry()
7656 {
7657 NameEntryMode=0;
7658 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7659 return D_O_K;
7660 }
7661
7662 int32_t onLetterGridEntry()
7663 {
7664 NameEntryMode=1;
7665 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7666 return D_O_K;
7667 }
7668
7669 int32_t onExtLetterGridEntry()
7670 {
7671 NameEntryMode=2;
7672 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7673 return D_O_K;
7674 }
7675
7676 static BITMAP* oldscreen;
7677 int32_t onFullscreenMenu()
7678 {
7679 // super hacks
7680 screen = oldscreen;
7681 if (onFullscreen() == D_REDRAW)
7682 {
7683 oldscreen = screen;
7684 }
7685 screen = menu_bmp;
7686 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7687 return D_O_K;
7688 }
7689
7690 38 void fix_menu()
7691 {
7692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(!debug_enabled)
7693 38 settings_menu[13].text = NULL;
7694 38 }
7695
7696 static DIALOG system_dlg[] =
7697 {
7698 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7699 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7700 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7701 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7702 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7703 #ifndef ALLEGRO_MACOSX
7704 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7705 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7706 #else
7707 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7708 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7709 #endif
7710 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7711 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7712 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7713 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7714 };
7715
7716 void reset_snapshot_format_menu()
7717 {
7718 for(int32_t i=0; i<ssfmtMAX; ++i)
7719 {
7720 snapshot_format_menu[i].flags=0;
7721 }
7722 }
7723
7724 int32_t onSetSnapshotFormat()
7725 {
7726 switch(active_menu->text[1])
7727 {
7728 case 'B': //"&BMP"
7729 SnapshotFormat=0;
7730 break;
7731
7732 case 'G': //"&GIF"
7733 SnapshotFormat=1;
7734 break;
7735
7736 case 'J': //"&JPG"
7737 SnapshotFormat=2;
7738 break;
7739
7740 case 'P': //"&PNG"
7741 SnapshotFormat=3;
7742 break;
7743
7744 case 'C': //"PC&X"
7745 SnapshotFormat=4;
7746 break;
7747
7748 case 'T': //"&TGA"
7749 SnapshotFormat=5;
7750 break;
7751
7752 case 'L': //"&LBM"
7753 SnapshotFormat=6;
7754 break;
7755 }
7756 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7757
7758 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7759 return D_O_K;
7760 }
7761
7762
7763 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7764 {
7765 PALETTE tmp;
7766
7767 for(int32_t i=0; i<256; i++)
7768 {
7769 tmp[i].r=r;
7770 tmp[i].g=g;
7771 tmp[i].b=b;
7772 }
7773
7774 fade_interpolate(src,tmp,dest,pos,from,to);
7775 }
7776
7777 51 void system_pal(bool force)
7778 {
7779
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
51 if(is_sys_pal && !force) return;
7780 51 is_sys_pal = true;
7781 51 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7782 51 hw_palette = &syspal;
7783 51 update_hw_pal = true;
7784 51 }
7785
7786 static uint32_t entered_sys_pal = 0;
7787 51 void enter_sys_pal()
7788 {
7789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(is_sys_pal)
7790 {
7791 if(entered_sys_pal)
7792 ++entered_sys_pal;
7793 return;
7794 }
7795 51 sys_mouse();
7796 51 system_pal(true);
7797 51 ++entered_sys_pal;
7798 51 }
7799 51 void exit_sys_pal()
7800 {
7801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(entered_sys_pal)
7802 {
7803
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!--entered_sys_pal)
7804 {
7805 51 game_pal();
7806 51 game_mouse();
7807 51 }
7808 51 }
7809 51 }
7810
7811 void switch_out_callback()
7812 {
7813 if (pause_in_background)
7814 {
7815 callback_switchin = 3;
7816 return;
7817 }
7818
7819 #ifdef _WIN32
7820 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
7821 return;
7822
7823
7824 paused_midi_pos = midi_pos;
7825 zc_stop_midi();
7826 midi_paused=true;
7827 midi_suspended = midissuspHALTED;
7828 #endif
7829 }
7830
7831 void switch_in_callback()
7832 {
7833 if(pause_in_background)
7834 {
7835 return;
7836 }
7837
7838 #ifdef _WIN32
7839 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
7840 return;
7841
7842 else
7843 {
7844 callback_switchin = 1;
7845 midi_suspended = midissuspRESUME;
7846 }
7847 #endif
7848 }
7849
7850 350 void game_pal()
7851 {
7852 350 is_sys_pal = false;
7853 350 entered_sys_pal = 0;
7854 350 hw_palette = &RAMpal;
7855 350 update_hw_pal = true;
7856 350 }
7857
7858 static char bar_str[] = "";
7859
7860 13 void music_pause()
7861 {
7862 //al_pause_duh(tmplayer);
7863 13 zcmusic_pause(zcmusic, ZCM_PAUSE);
7864 13 zc_midi_pause();
7865 13 midi_paused=true;
7866 13 }
7867
7868 void music_resume()
7869 {
7870 //al_resume_duh(tmplayer);
7871 zcmusic_pause(zcmusic, ZCM_RESUME);
7872 zc_midi_resume();
7873 midi_paused=false;
7874 }
7875
7876 6596 void music_stop()
7877 {
7878 //al_stop_duh(tmplayer);
7879 //unload_duh(tmusic);
7880 //tmusic=NULL;
7881 //tmplayer=NULL;
7882 6596 zcmusic_stop(zcmusic);
7883 6596 zcmusic_unload_file(zcmusic);
7884 6596 zc_stop_midi();
7885 6596 midi_paused=false;
7886 6596 currmidi=-1;
7887 6596 }
7888
7889 void System()
7890 {
7891 mouse_down=gui_mouse_b();
7892 music_pause();
7893 pause_all_sfx();
7894 MenuOpen = true;
7895 enter_sys_pal();
7896 // FONT *oldfont=font;
7897 // font=tfont;
7898
7899 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7900 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7901
7902 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7903 #if DEVLEVEL > 1
7904 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7905 #endif
7906 game_menu[3].flags =
7907 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7908 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7909 clear_keybuf();
7910
7911 DIALOG_PLAYER *p;
7912
7913 clear_bitmap(menu_bmp);
7914 oldscreen = screen;
7915 screen = menu_bmp;
7916
7917 p = init_dialog(system_dlg,-1);
7918
7919 // drop the menu on startup if menu button pressed
7920 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7921 simulate_keypress(KEY_G << 8);
7922
7923 do
7924 {
7925 if(close_button_quit)
7926 {
7927 close_button_quit = false;
7928 f_Quit(qEXIT);
7929 if(Quit) break;
7930 }
7931 rest(17);
7932
7933 if(mouse_down && !gui_mouse_b())
7934 mouse_down=0;
7935
7936 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
7937 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
7938 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
7939
7940 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7941 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7942 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7943 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7944 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7945 settings_menu[10].flags = NESquit?D_SELECTED:0;
7946 settings_menu[11].flags = volkeys?D_SELECTED:0;
7947
7948 window_menu[0].flags = DragAspect?D_SELECTED:0;
7949 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7950 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7951 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7952 window_menu[4].flags = stretchGame?D_SELECTED:0;
7953
7954 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7955 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
7956
7957 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7958 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7959 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7960
7961 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7962 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7963 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7964
7965 bool nocheat = (replay_is_replaying() || !Playing
7966 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7967 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7968 cheat_menu[0].flags = 0;
7969 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
7970 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7971 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7972 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7973 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7974 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7975 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7976 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7977 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7978
7979 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7980 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7981 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7982 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7983 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7984 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7985 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7986 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7987 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7988 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7989 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7990 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7991 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7992 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7993 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7994
7995 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7996 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7997
7998 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7999 (char *)"Disable recording new saves" :
8000 (char *)"Enable recording new saves";
8001 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8002 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8003 (char *)"Stop recording" :
8004 (char *)"Stop replaying";
8005 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8006 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8007 (char *)"Disable snapshot all frames" :
8008 (char *)"Enable snapshot all frames";
8009
8010 reset_snapshot_format_menu();
8011 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8012
8013 if(debug_enabled)
8014 {
8015 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8016 }
8017
8018 if(gui_mouse_b() && !mouse_down)
8019 break;
8020
8021 // press menu to drop the menu
8022 if(rMbtn())
8023 simulate_keypress(KEY_G << 8);
8024
8025 if(input_idle(true) > after_time())
8026 // run Screeen Saver
8027 {
8028 // Screen saver enabled for now.
8029 clear_keybuf();
8030 Matrix(ss_speed, ss_density, 0);
8031 system_pal();
8032 sys_mouse();
8033 broadcast_dialog_message(MSG_DRAW, 0);
8034 }
8035
8036 update_hw_screen();
8037 }
8038 while(update_dialog(p));
8039
8040 screen = oldscreen;
8041
8042 // font=oldfont;
8043 mouse_down=gui_mouse_b();
8044 shutdown_dialog(p);
8045 MenuOpen = false;
8046 if(Quit)
8047 {
8048 kill_sfx();
8049 music_stop();
8050 update_hw_screen();
8051 }
8052 else
8053 {
8054 music_resume();
8055 resume_all_sfx();
8056
8057 if(rc)
8058 ringcolor(false);
8059 }
8060 exit_sys_pal();
8061
8062 eat_buttons();
8063
8064 rc=false;
8065 clear_keybuf();
8066 // text_mode(0);
8067 }
8068
8069 38 void fix_dialogs()
8070 {
8071 38 jwin_center_dialog(about_dlg);
8072 38 jwin_center_dialog(gamepad_dlg);
8073 38 jwin_center_dialog(credits_dlg);
8074 38 jwin_center_dialog(gamemode_dlg);
8075 38 jwin_center_dialog(getnum_dlg);
8076 38 jwin_center_dialog(goto_dlg);
8077 38 jwin_center_dialog(keyboard_control_dlg);
8078 38 jwin_center_dialog(midi_dlg);
8079 38 jwin_center_dialog(quest_dlg);
8080 38 jwin_center_dialog(scrsaver_dlg);
8081 38 jwin_center_dialog(sound_dlg);
8082 38 jwin_center_dialog(triforce_dlg);
8083
8084 // digi_dp[1] += scrx;
8085 // digi_dp[2] += scry;
8086 // midi_dp[1] += scrx;
8087 // midi_dp[2] += scry;
8088 // pan_dp[1] += scrx;
8089 // pan_dp[2] += scry;
8090 // emus_dp[1] += scrx;
8091 // emus_dp[2] += scry;
8092 // buf_dp[1] += scrx;
8093 // buf_dp[2] += scry;
8094 // sfx_dp[1] += scrx;
8095 // sfx_dp[2] += scry;
8096 38 }
8097
8098 /*****************************/
8099 /**** Custom Sound System ****/
8100 /*****************************/
8101
8102 2898 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8103 {
8104
3/4
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2898 times.
✗ Branch 3 not taken.
2898 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8105 }
8106
8107 // Run an NSF, or a MIDI if the NSF is missing somehow.
8108 106 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8109 {
8110 106 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8111
8112 // Found it
8113
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 38 times.
106 if(newzcmusic!=NULL)
8114 {
8115 68 zcmusic_stop(zcmusic);
8116 68 zcmusic_unload_file(zcmusic);
8117 68 zc_stop_midi();
8118
8119 68 zcmusic=newzcmusic;
8120 68 zcmusic_play(zcmusic, emusic_volume);
8121
8122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(track>0)
8123 68 zcmusic_change_track(zcmusic,track);
8124
8125 68 return true;
8126 }
8127
8128 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8129
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 else if(midi>-1000)
8130 jukebox(midi);
8131
8132 38 return false;
8133 106 }
8134
8135 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8136 {
8137 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8138 // Found it
8139 if(newzcmusic!=NULL)
8140 {
8141 zcmusic_stop(zcmusic);
8142 zcmusic_unload_file(zcmusic);
8143 zc_stop_midi();
8144
8145 zcmusic=newzcmusic;
8146 zcmusic_play(zcmusic, emusic_volume);
8147
8148 if(track>0)
8149 zcmusic_change_track(zcmusic,track);
8150
8151 return true;
8152 }
8153
8154 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8155 else if(midi>-1000)
8156 jukebox(midi);
8157
8158 return false;
8159 }
8160
8161 int32_t get_zcmusicpos()
8162 {
8163 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8164 return debugtracething;
8165 return 0;
8166 }
8167
8168 void set_zcmusicpos(int32_t position)
8169 {
8170 zcmusic_set_curpos(zcmusic, position);
8171 }
8172
8173 void set_zcmusicspeed(int32_t speed)
8174 {
8175 int32_t newspeed = vbound(speed, 0, 10000);
8176 zcmusic_set_speed(zcmusic, newspeed);
8177 }
8178
8179 1430 void jukebox(int32_t index,int32_t loop)
8180 {
8181 1430 music_stop();
8182
8183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(index<0) index=MAXMIDIS-1;
8184
8185
1/2
✓ Branch 0 taken 1430 times.
✗ Branch 1 not taken.
1430 if(index>=MAXMIDIS) index=0;
8186
8187 1430 music_stop();
8188
8189 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8190 // stuck notes when a song stops. This fixes it.
8191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(strcmp(midi_driver->name, "DIGMID")==0)
8192 zc_set_volume(0, 0);
8193
8194 1430 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8195 1430 zc_play_midi((MIDI*)tunes[index].data,loop);
8196
8197
2/2
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 402 times.
1430 if(tunes[index].start>0)
8198 402 zc_midi_seek(tunes[index].start);
8199
8200 1430 midi_loop_start = tunes[index].loop_start;
8201 1430 midi_loop_end = tunes[index].loop_end;
8202
8203 1430 currmidi=index;
8204 1430 master_volume(digi_volume,midi_volume);
8205 1430 midi_paused=false;
8206 1430 }
8207
8208 11407 void jukebox(int32_t index)
8209 {
8210
1/2
✓ Branch 0 taken 11407 times.
✗ Branch 1 not taken.
11407 if(index<0) index=MAXMIDIS-1;
8211
8212
1/2
✓ Branch 0 taken 11407 times.
✗ Branch 1 not taken.
11407 if(index>=MAXMIDIS) index=0;
8213
8214 // do nothing if it's already playing
8215
3/4
✓ Branch 0 taken 9977 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 9977 times.
✗ Branch 3 not taken.
11407 if(index==currmidi && midi_pos>=0)
8216 {
8217 9977 midi_paused=false;
8218 9977 return;
8219 }
8220
8221 1430 jukebox(index,tunes[index].loop);
8222 11407 }
8223
8224 12748 void play_DmapMusic()
8225 {
8226 static char tfile[2048];
8227 static int32_t ttrack=0;
8228 12748 bool domidi=false;
8229
8230
2/2
✓ Branch 0 taken 1462 times.
✓ Branch 1 taken 11286 times.
12748 if(DMaps[currdmap].tmusic[0]!=0)
8231 {
8232
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1847 if(zcmusic==NULL ||
8233
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8234
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8235 {
8236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1077 times.
1077 if(zcmusic != NULL)
8237 {
8238 zcmusic_stop(zcmusic);
8239 zcmusic_unload_file(zcmusic);
8240 zcmusic = NULL;
8241 }
8242
8243 1077 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8244
8245
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 990 times.
1077 if(zcmusic!=NULL)
8246 {
8247 87 zc_stop_midi();
8248 87 strcpy(tfile,DMaps[currdmap].tmusic);
8249 87 zcmusic_play(zcmusic, emusic_volume);
8250 87 int32_t temptracks=0;
8251 87 temptracks=zcmusic_get_tracks(zcmusic);
8252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 temptracks=(temptracks<2)?1:temptracks;
8253 87 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8254 87 zcmusic_change_track(zcmusic,ttrack);
8255 87 }
8256 else
8257 {
8258 990 tfile[0] = 0;
8259 990 domidi=true;
8260 }
8261 1077 }
8262 1462 }
8263 else
8264 {
8265 11286 domidi=true;
8266 }
8267
8268
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 12276 times.
12748 if(domidi)
8269 {
8270 12276 int32_t m=DMaps[currdmap].midi;
8271
8272
3/4
✓ Branch 0 taken 11884 times.
✓ Branch 1 taken 373 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
12276 switch(m)
8273 {
8274 case 1:
8275 373 jukebox(ZC_MIDI_OVERWORLD);
8276 373 break;
8277
8278 case 2:
8279 19 jukebox(ZC_MIDI_DUNGEON);
8280 19 break;
8281
8282 case 3:
8283 jukebox(ZC_MIDI_LEVEL9);
8284 break;
8285
8286 default:
8287
3/4
✓ Branch 0 taken 10843 times.
✓ Branch 1 taken 1041 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10843 times.
11884 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8288 10843 jukebox(m+MIDIOFFSET_DMAP);
8289 else
8290 1041 music_stop();
8291 11884 }
8292 12276 }
8293 12748 }
8294
8295 12786 void playLevelMusic()
8296 {
8297 12786 int32_t m=tmpscr->screen_midi;
8298
8299
3/6
✓ Branch 0 taken 12732 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
12786 switch(m)
8300 {
8301 case -2:
8302 13 music_stop();
8303 13 break;
8304
8305 case -1:
8306 12732 play_DmapMusic();
8307 12732 break;
8308
8309 case 1:
8310 jukebox(ZC_MIDI_OVERWORLD);
8311 break;
8312
8313 case 2:
8314 jukebox(ZC_MIDI_DUNGEON);
8315 break;
8316
8317 case 3:
8318 jukebox(ZC_MIDI_LEVEL9);
8319 break;
8320
8321 default:
8322
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8323 41 jukebox(m+MIDIOFFSET_MAPSCR);
8324 else
8325 music_stop();
8326 41 }
8327 12786 }
8328
8329 1468 void master_volume(int32_t dv,int32_t mv)
8330 {
8331
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1468 times.
✓ Branch 2 taken 1468 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1468 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1468 times.
✗ Branch 7 not taken.
1468 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8332
8333
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1468 times.
✓ Branch 2 taken 1468 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1468 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1468 times.
✗ Branch 7 not taken.
1468 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8334
8335
6/6
✓ Branch 0 taken 1427 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 1466 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1425 times.
✓ Branch 5 taken 41 times.
1468 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8336 1468 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8337 1468 }
8338
8339 /*****************/
8340 /***** SFX *****/
8341 /*****************/
8342
8343 // array of voices, one for each sfx sample in the data file
8344 // 0+ = voice #
8345 // -1 = voice not allocated
8346 38 void Z_init_sound()
8347 {
8348
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 38 times.
9766 for(int32_t i=0; i<WAV_COUNT; i++)
8349 9728 sfx_voice[i]=-1;
8350
8351
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 38 times.
304 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8352 266 tunes[i].data = (MIDI*)mididata[i].dat;
8353
8354
2/2
✓ Branch 0 taken 9576 times.
✓ Branch 1 taken 38 times.
9614 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8355 9576 tunes[ZC_MIDI_COUNT+j].data=NULL;
8356
8357 38 master_volume(digi_volume,midi_volume);
8358 38 }
8359
8360 // returns number of voices currently allocated
8361 int32_t sfx_count()
8362 {
8363 int32_t c=0;
8364
8365 for(int32_t i=0; i<WAV_COUNT; i++)
8366 if(sfx_voice[i]!=-1)
8367 ++c;
8368
8369 return c;
8370 }
8371
8372 // clean up finished samples
8373 8069694 void sfx_cleanup()
8374 {
8375
2/2
✓ Branch 0 taken 2065841664 times.
✓ Branch 1 taken 8069694 times.
2073911358 for(int32_t i=0; i<WAV_COUNT; i++)
8376
3/4
✓ Branch 0 taken 633784 times.
✓ Branch 1 taken 2065207880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 633784 times.
2066475448 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8377 {
8378 633784 deallocate_voice(sfx_voice[i]);
8379 633784 sfx_voice[i]=-1;
8380 633784 }
8381 8069694 }
8382
8383 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8384 // if a voice is already allocated (and/or playing), then it just returns true
8385 // Returns true: voice is allocated
8386 // false: unsuccessful
8387 974415 bool sfx_init(int32_t index)
8388 {
8389 // check index
8390
3/4
✓ Branch 0 taken 702705 times.
✓ Branch 1 taken 271710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 702705 times.
974415 if(index<=0 || index>=WAV_COUNT)
8391 271710 return false;
8392
8393
2/2
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 633811 times.
702705 if(sfx_voice[index]==-1)
8394 {
8395
2/2
✓ Branch 0 taken 182177 times.
✓ Branch 1 taken 451634 times.
633811 if(sfxdat)
8396 {
8397
1/2
✓ Branch 0 taken 182177 times.
✗ Branch 1 not taken.
182177 if(index<Z35)
8398 {
8399 182177 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8400 182177 }
8401 else
8402 {
8403 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8404 }
8405 182177 }
8406 else
8407 {
8408 451634 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8409 }
8410
8411 633811 voice_set_volume(sfx_voice[index], sfx_volume);
8412 633811 }
8413
8414 702705 return sfx_voice[index] != -1;
8415 974415 }
8416
8417 // plays an sfx sample
8418 829949 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8419 {
8420
2/2
✓ Branch 0 taken 630945 times.
✓ Branch 1 taken 199004 times.
829949 if(!sfx_init(index))
8421 199004 return;
8422
8423 630945 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8424 630945 voice_set_pan(sfx_voice[index],pan);
8425
8426 630945 int32_t pos = voice_get_position(sfx_voice[index]);
8427
8428
2/2
✓ Branch 0 taken 298046 times.
✓ Branch 1 taken 332899 times.
630945 if(restart) voice_set_position(sfx_voice[index],0);
8429
8430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630945 times.
630945 if(pos<=0)
8431 630945 voice_start(sfx_voice[index]);
8432
8433
3/4
✓ Branch 0 taken 332899 times.
✓ Branch 1 taken 298046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 332899 times.
630945 if (restart && replay_is_debug())
8434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332899 times.
332899 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8435 829949 }
8436
8437 // true if sfx is allocated
8438 35890 bool sfx_allocated(int32_t index)
8439 {
8440
3/4
✓ Branch 0 taken 9407 times.
✓ Branch 1 taken 26483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9407 times.
35890 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8441 }
8442
8443 // start it (in loop mode) if it's not already playing,
8444 // otherwise adjust it to play in loop mode -DD
8445 144466 void cont_sfx(int32_t index)
8446 {
8447
2/2
✓ Branch 0 taken 72706 times.
✓ Branch 1 taken 71760 times.
144466 if(!sfx_init(index))
8448 {
8449 72706 return;
8450 }
8451
8452
1/2
✓ Branch 0 taken 71760 times.
✗ Branch 1 not taken.
71760 if(voice_get_position(sfx_voice[index])<=0)
8453 {
8454 71760 voice_set_position(sfx_voice[index],0);
8455 71760 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8456 71760 voice_start(sfx_voice[index]);
8457 71760 }
8458 else
8459 {
8460 adjust_sfx(index, 128, true);
8461 }
8462 144466 }
8463
8464 // adjust parameters while playing
8465 3961 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8466 {
8467
5/6
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2187 times.
3961 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8468 3947 return;
8469
8470 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8471 14 voice_set_pan(sfx_voice[index],pan);
8472 3961 }
8473
8474 // pauses a voice
8475 1651 void pause_sfx(int32_t index)
8476 {
8477
3/6
✓ Branch 0 taken 1651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1651 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1651 times.
1651 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8478 voice_stop(sfx_voice[index]);
8479 1651 }
8480
8481 // resumes a voice
8482 709 void resume_sfx(int32_t index)
8483 {
8484
3/6
✓ Branch 0 taken 709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 709 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 709 times.
709 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8485 voice_start(sfx_voice[index]);
8486 709 }
8487
8488 // pauses all active voices
8489 319 void pause_all_sfx()
8490 {
8491
2/2
✓ Branch 0 taken 81664 times.
✓ Branch 1 taken 319 times.
81983 for(int32_t i=0; i<WAV_COUNT; i++)
8492
2/2
✓ Branch 0 taken 81663 times.
✓ Branch 1 taken 1 times.
81665 if(sfx_voice[i]!=-1)
8493 1 voice_stop(sfx_voice[i]);
8494 319 }
8495
8496 // resumes all paused voices
8497 306 void resume_all_sfx()
8498 {
8499
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 306 times.
78642 for(int32_t i=0; i<WAV_COUNT; i++)
8500
1/2
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
78336 if(sfx_voice[i]!=-1)
8501 voice_start(sfx_voice[i]);
8502 306 }
8503
8504 // stops an sfx and deallocates the voice
8505 6464623 void stop_sfx(int32_t index)
8506 {
8507
3/4
✓ Branch 0 taken 5323422 times.
✓ Branch 1 taken 1141201 times.
✓ Branch 2 taken 5323422 times.
✗ Branch 3 not taken.
6464623 if(index<=0 || index>=WAV_COUNT)
8508 1141201 return;
8509
8510
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5323409 times.
5323422 if(sfx_voice[index]!=-1)
8511 {
8512 13 deallocate_voice(sfx_voice[index]);
8513 13 sfx_voice[index]=-1;
8514 13 }
8515 6464623 }
8516
8517 // Stops SFX played by Hero's item of the given family
8518 127218 void stop_item_sfx(int32_t family)
8519 {
8520 127218 int32_t id=current_item_id(family);
8521
8522
2/2
✓ Branch 0 taken 126752 times.
✓ Branch 1 taken 466 times.
127218 if(id<0)
8523 126752 return;
8524
8525 466 stop_sfx(itemsbuf[id].usesound);
8526 127218 }
8527
8528 2356 void kill_sfx()
8529 {
8530
2/2
✓ Branch 0 taken 603136 times.
✓ Branch 1 taken 2356 times.
605492 for(int32_t i=0; i<WAV_COUNT; i++)
8531
2/2
✓ Branch 0 taken 603122 times.
✓ Branch 1 taken 14 times.
603150 if(sfx_voice[i]!=-1)
8532 {
8533 14 deallocate_voice(sfx_voice[i]);
8534 14 sfx_voice[i]=-1;
8535 14 }
8536 2356 }
8537
8538 583997 int32_t pan(int32_t x)
8539 {
8540
1/4
✓ Branch 0 taken 583997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
583997 switch(pan_style)
8541 {
8542 case 0:
8543 return 128;
8544
8545 case 1:
8546 583997 return vbound((x>>1)+68,0,255);
8547
8548 case 2:
8549 return vbound(((x*3)>>2)+36,0,255);
8550 }
8551
8552 return vbound(x,0,255);
8553 583997 }
8554
8555 /*******************************/
8556 /******* Input Handlers ********/
8557 /*******************************/
8558
8559 21716077 bool joybtn(int32_t b)
8560 {
8561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21716077 times.
21716077 if(b == 0)
8562 return false;
8563
8564 21716077 return joy[joystick_index].button[b-1].b !=0;
8565 21716077 }
8566
8567 const char* joybtn_name(int32_t b)
8568 {
8569 if(b == 0)
8570 return "";
8571
8572 return joy[joystick_index].button[b-1].name;
8573 }
8574
8575 int32_t next_press_key();
8576
8577 int32_t next_press_btn()
8578 {
8579 clear_keybuf();
8580 /*bool b[joy[joystick_index].num_buttons+1];
8581
8582 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8583 b[i]=joybtn(i);*/
8584
8585 //first, we need to wait until they're pressing no buttons
8586 for(;;)
8587 {
8588 if(keypressed())
8589 {
8590 switch(readkey()>>8)
8591 {
8592 case KEY_ESC:
8593 return -1;
8594
8595 case KEY_SPACE:
8596 return 0;
8597 }
8598 }
8599
8600 poll_joystick();
8601 bool done = true;
8602
8603 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8604 {
8605 if(joybtn(i)) done = false;
8606 }
8607
8608 if(done) break;
8609 rest(1);
8610 }
8611
8612 //now, we need to wait for them to press any button
8613 for(;;)
8614 {
8615 if(keypressed())
8616 {
8617 switch(readkey()>>8)
8618 {
8619 case KEY_ESC:
8620 return -1;
8621
8622 case KEY_SPACE:
8623 return 0;
8624 }
8625 }
8626
8627 poll_joystick();
8628
8629 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8630 {
8631 if(joybtn(i)) return i;
8632 }
8633 rest(1);
8634 }
8635 }
8636
8637 168139528 static bool rButton(bool &btn, bool &flag)
8638 {
8639
2/2
✓ Branch 0 taken 162259590 times.
✓ Branch 1 taken 5879938 times.
168139528 bool ret = btn && !flag;
8640 168139528 flag = btn;
8641
8642 168139528 return ret;
8643 }
8644 1648122 static bool rButtonPeek(bool btn, bool flag)
8645 {
8646
2/2
✓ Branch 0 taken 1535358 times.
✓ Branch 1 taken 112764 times.
1648122 if(!btn)
8647 {
8648 1535358 return false;
8649 }
8650
2/2
✓ Branch 0 taken 16429 times.
✓ Branch 1 taken 96335 times.
112764 else if(!flag)
8651 {
8652 16429 return true;
8653 }
8654
8655 96335 return false;
8656 1648122 }
8657
8658 // Updated only by keyboard/gamepad.
8659 // If in replay mode, this is set directly by the replay system.
8660 // This should never be read from directly - use control_state instead.
8661 bool raw_control_state[ZC_CONTROL_STATES];
8662
8663 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8664 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8665 // lasts until the next call to load_control_state.
8666 bool control_state[ZC_CONTROL_STATES];
8667 bool disable_control[ZC_CONTROL_STATES];
8668 bool drunk_toggle_state[11];
8669 bool disabledKeys[127];
8670 bool KeyInput[127];
8671 bool KeyPress[127];
8672
8673 bool key_current_frame[127];
8674 bool key_previous_frame[127];
8675
8676 static bool key_system[127];
8677 static bool key_system_previous[127];
8678 static bool key_system_press[127];
8679
8680 bool button_press[ZC_CONTROL_STATES];
8681 bool button_hold[ZC_CONTROL_STATES];
8682
8683 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8684 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8685 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8686 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8687 #define STICK_PRECISION 56 //define your own sensitivity
8688
8689 6802038 void load_control_state()
8690 {
8691 6802038 load_control_called_this_frame = true;
8692
8693
4/4
✓ Branch 0 taken 3930837 times.
✓ Branch 1 taken 2871201 times.
✓ Branch 2 taken 1278552 times.
✓ Branch 3 taken 2652285 times.
6802038 if (replay_get_version() >= 8 && replay_get_version() < 11)
8694 {
8695
2/2
✓ Branch 0 taken 47741130 times.
✓ Branch 1 taken 2652285 times.
50393415 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8696 47741130 down_control_states[i] = raw_control_state[i];
8697 2652285 }
8698
8699
1/2
✓ Branch 0 taken 6802038 times.
✗ Branch 1 not taken.
6802038 if (!replay_is_replaying())
8700 {
8701 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8702 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8703 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8704 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8705 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8706 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8707 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8708 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8709 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8710 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8711 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8712 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8713 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8714 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8715
8716 if(num_joysticks != 0)
8717 {
8718 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8719 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8720 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8721 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8722 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8723 }
8724 else
8725 {
8726 raw_control_state[14] = false;
8727 raw_control_state[15] = false;
8728 raw_control_state[16] = false;
8729 raw_control_state[17] = false;
8730 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8731 }
8732 bool did_bad_cutscene_btn = false;
8733 for(int q = 0; q < 18; ++q)
8734 if(raw_control_state[q] && !active_cutscene.can_button(q))
8735 {
8736 raw_control_state[q] = false;
8737 did_bad_cutscene_btn = true;
8738 }
8739 if(did_bad_cutscene_btn)
8740 active_cutscene.error();
8741 }
8742
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6802035 times.
6802038 if (replay_is_active())
8743 {
8744
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5786820 times.
6802035 if (replay_get_version() < 3)
8745 1015215 replay_poll();
8746
3/4
✓ Branch 0 taken 5786820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4025445 times.
✓ Branch 3 taken 1761375 times.
5786820 else if (replay_is_replaying() && replay_get_version() < 6)
8747 1761375 replay_peek_input();
8748
5/6
✓ Branch 0 taken 4025445 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3930837 times.
✓ Branch 3 taken 94608 times.
✓ Branch 4 taken 1278552 times.
✓ Branch 5 taken 2652285 times.
4025445 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
8749 2652285 replay_peek_input();
8750
2/2
✓ Branch 0 taken 5697745 times.
✓ Branch 1 taken 1104290 times.
6802035 if (replay_get_version() == 8)
8751 1104290 update_keys();
8752 6802035 }
8753
8754 // Some test replay files were made before a serious input bug was fixed, so instead
8755 // of re-doing them or tossing them out, just check for that zplay version.
8756
3/4
✓ Branch 0 taken 6802032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6680132 times.
6802038 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8757
2/2
✓ Branch 0 taken 122436576 times.
✓ Branch 1 taken 6802032 times.
129238608 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8758 {
8759 122436576 control_state[i] = raw_control_state[i];
8760
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 72949266 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
122436576 if (botched_input && !control_state[i])
8761 47077142 down_control_states[i] = false;
8762 122436576 }
8763
8764 6802032 button_press[0]=rButton(control_state[0],button_hold[0]);
8765 6802032 button_press[1]=rButton(control_state[1],button_hold[1]);
8766 6802032 button_press[2]=rButton(control_state[2],button_hold[2]);
8767 6802032 button_press[3]=rButton(control_state[3],button_hold[3]);
8768 6802032 button_press[4]=rButton(control_state[4],button_hold[4]);
8769 6802032 button_press[5]=rButton(control_state[5],button_hold[5]);
8770 6802032 button_press[6]=rButton(control_state[6],button_hold[6]);
8771 6802032 button_press[7]=rButton(control_state[7],button_hold[7]);
8772 6802032 button_press[8]=rButton(control_state[8],button_hold[8]);
8773 6802032 button_press[9]=rButton(control_state[9],button_hold[9]);
8774 6802032 button_press[10]=rButton(control_state[10],button_hold[10]);
8775 6802032 button_press[11]=rButton(control_state[11],button_hold[11]);
8776 6802032 button_press[12]=rButton(control_state[12],button_hold[12]);
8777 6802032 button_press[13]=rButton(control_state[13],button_hold[13]);
8778 6802032 button_press[14]=rButton(control_state[14],button_hold[14]);
8779 6802032 button_press[15]=rButton(control_state[15],button_hold[15]);
8780 6802032 button_press[16]=rButton(control_state[16],button_hold[16]);
8781 6802032 button_press[17]=rButton(control_state[17],button_hold[17]);
8782 6802032 }
8783
8784 // Returns true if any game key is pressed. This is needed because keypressed()
8785 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8786 35288690 bool zc_key_pressed()
8787 //may also need to use zc_getrawkey
8788 {
8789
7/10
✓ Branch 0 taken 28586336 times.
✓ Branch 1 taken 6702354 times.
✓ Branch 2 taken 6702354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6702354 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5618218 times.
✓ Branch 7 taken 5618218 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2127588 times.
37416278 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8790
4/6
✓ Branch 0 taken 5618218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5618218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4254196 times.
✓ Branch 5 taken 4254196 times.
5618218 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8791
4/6
✓ Branch 0 taken 4254196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4254196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2746816 times.
✓ Branch 5 taken 2746816 times.
4254196 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8792
4/6
✓ Branch 0 taken 2746816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2746816 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2380949 times.
✓ Branch 5 taken 2380949 times.
2746816 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8793
1/2
✓ Branch 0 taken 2380949 times.
✗ Branch 1 not taken.
2380949 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8794
3/4
✓ Branch 0 taken 2265185 times.
✓ Branch 1 taken 115764 times.
✓ Branch 2 taken 2265185 times.
✗ Branch 3 not taken.
2380949 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8795
3/4
✓ Branch 0 taken 2157280 times.
✓ Branch 1 taken 107905 times.
✓ Branch 2 taken 2157280 times.
✗ Branch 3 not taken.
2265185 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8796
3/4
✓ Branch 0 taken 2142789 times.
✓ Branch 1 taken 14491 times.
✓ Branch 2 taken 2142789 times.
✗ Branch 3 not taken.
2157280 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8797
3/4
✓ Branch 0 taken 2130211 times.
✓ Branch 1 taken 12578 times.
✓ Branch 2 taken 2130211 times.
✗ Branch 3 not taken.
2142789 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8798
3/4
✓ Branch 0 taken 2128467 times.
✓ Branch 1 taken 1744 times.
✓ Branch 2 taken 2128467 times.
✗ Branch 3 not taken.
2130211 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8799
3/4
✓ Branch 0 taken 2128394 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 2128394 times.
✗ Branch 3 not taken.
2128467 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8800
3/4
✓ Branch 0 taken 2127607 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 2127607 times.
✗ Branch 3 not taken.
2128394 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8801
2/4
✓ Branch 0 taken 2127607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127607 times.
✗ Branch 3 not taken.
2127607 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8802
2/2
✓ Branch 0 taken 2127588 times.
✓ Branch 1 taken 19 times.
2127607 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8803 63161460 return true;
8804
8805 2127588 return false;
8806 8116376 }
8807
8808 133539461 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8809 {
8810 133539461 bool ret = false, drunkstate = false;
8811 133539461 bool* flag = &down_control_states[btn];
8812
2/7
✓ Branch 0 taken 125414593 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 8124868 times.
133539461 switch(btn)
8813 {
8814 case btnF12:
8815 ret = zc_getkey(KEY_F12, ignoreDisable);
8816 eatEntirely = false;
8817 break;
8818 case btnF11:
8819 ret = zc_getkey(KEY_F11, ignoreDisable);
8820 eatEntirely = false;
8821 break;
8822 case btnF5:
8823 ret = zc_getkey(KEY_F5, ignoreDisable);
8824 eatEntirely = false;
8825 break;
8826 case btnQ:
8827 ret = zc_getkey(KEY_Q, ignoreDisable);
8828 eatEntirely = false;
8829 break;
8830 case btnI:
8831 ret = zc_getkey(KEY_I, ignoreDisable);
8832 eatEntirely = false;
8833 break;
8834 case btnM:
8835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8124868 times.
8124868 if(FFCore.kb_typing_mode) return false;
8836 8124868 ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8837 8124868 eatEntirely = false;
8838 8124868 break;
8839 default: //control_state[] index
8840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125414593 times.
125414593 if(FFCore.kb_typing_mode) return false;
8841
5/6
✓ Branch 0 taken 124967406 times.
✓ Branch 1 taken 447187 times.
✓ Branch 2 taken 2038236 times.
✓ Branch 3 taken 122929170 times.
✓ Branch 4 taken 2038236 times.
✗ Branch 5 not taken.
125414593 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8842
2/2
✓ Branch 0 taken 6781340 times.
✓ Branch 1 taken 118633253 times.
125414593 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8843
4/4
✓ Branch 0 taken 113054048 times.
✓ Branch 1 taken 12360545 times.
✓ Branch 2 taken 5041 times.
✓ Branch 3 taken 12355504 times.
137775138 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8844 125414593 }
8845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133539461 times.
133539461 assert(flag);
8846
2/2
✓ Branch 0 taken 86188387 times.
✓ Branch 1 taken 47351074 times.
133539461 if(press)
8847 {
8848
2/2
✓ Branch 0 taken 1648122 times.
✓ Branch 1 taken 45702952 times.
47351074 if(peek)
8849 1648122 ret = rButtonPeek(ret, *flag);
8850 45702952 else ret = rButton(ret, *flag);
8851 47351074 }
8852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133539461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133539461 if(eatEntirely && ret) control_state[btn] = false;
8853
3/4
✓ Branch 0 taken 101051640 times.
✓ Branch 1 taken 32487821 times.
✓ Branch 2 taken 101051640 times.
✗ Branch 3 not taken.
133539461 if(drunk && drunkstate) ret = !ret;
8854 133539461 return ret;
8855 133539461 }
8856
8857 6554184 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8858 {
8859 6554184 byte ret = 0;
8860
2/2
✓ Branch 0 taken 4903972 times.
✓ Branch 1 taken 1650212 times.
6554184 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8861
2/2
✓ Branch 0 taken 6553622 times.
✓ Branch 1 taken 562 times.
6554184 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8862
2/2
✓ Branch 0 taken 6553747 times.
✓ Branch 1 taken 437 times.
6554184 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8863
2/2
✓ Branch 0 taken 6553747 times.
✓ Branch 1 taken 437 times.
6554184 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8864
2/2
✓ Branch 0 taken 6553747 times.
✓ Branch 1 taken 437 times.
6554184 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8865
2/2
✓ Branch 0 taken 6553747 times.
✓ Branch 1 taken 437 times.
6554184 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8866
2/2
✓ Branch 0 taken 6553747 times.
✓ Branch 1 taken 437 times.
6554184 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8867
2/2
✓ Branch 0 taken 6553747 times.
✓ Branch 1 taken 437 times.
6554184 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8868 6554184 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8869 }
8870
8871 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8872 {
8873 1114 return intbtn&vals;
8874 }
8875
8876 1575575 bool Up()
8877 {
8878 1575575 return getInput(btnUp);
8879 }
8880 99517 bool Down()
8881 {
8882 99517 return getInput(btnDown);
8883 }
8884 190751 bool Left()
8885 {
8886 190751 return getInput(btnLeft);
8887 }
8888 213719 bool Right()
8889 {
8890 213719 return getInput(btnRight);
8891 }
8892 112761 bool cAbtn()
8893 {
8894 112761 return getInput(btnA);
8895 }
8896 1333347 bool cBbtn()
8897 {
8898 1333347 return getInput(btnB);
8899 }
8900 bool cSbtn()
8901 {
8902 return getInput(btnS);
8903 }
8904 46682 bool cLbtn()
8905 {
8906 46682 return getInput(btnL);
8907 }
8908 46682 bool cRbtn()
8909 {
8910 46682 return getInput(btnR);
8911 }
8912 bool cPbtn()
8913 {
8914 return getInput(btnP);
8915 }
8916 bool cEx1btn()
8917 {
8918 return getInput(btnEx1);
8919 }
8920 bool cEx2btn()
8921 {
8922 return getInput(btnEx2);
8923 }
8924 bool cEx3btn()
8925 {
8926 return getInput(btnEx3);
8927 }
8928 bool cEx4btn()
8929 {
8930 return getInput(btnEx4);
8931 }
8932 bool AxisUp()
8933 {
8934 return getInput(btnAxisUp);
8935 }
8936 bool AxisDown()
8937 {
8938 return getInput(btnAxisDown);
8939 }
8940 bool AxisLeft()
8941 {
8942 return getInput(btnAxisLeft);
8943 }
8944 bool AxisRight()
8945 {
8946 return getInput(btnAxisRight);
8947 }
8948
8949 bool cMbtn()
8950 {
8951 return getInput(btnM);
8952 }
8953 bool cF12()
8954 {
8955 return getInput(btnF12);
8956 }
8957 bool cF11()
8958 {
8959 return getInput(btnF11);
8960 }
8961 bool cF5()
8962 {
8963 return getInput(btnF5);
8964 }
8965 bool cQ()
8966 {
8967 return getInput(btnQ);
8968 }
8969 bool cI()
8970 {
8971 return getInput(btnI);
8972 }
8973
8974 127703 bool rUp()
8975 {
8976 127703 return getInput(btnUp, true);
8977 }
8978 127609 bool rDown()
8979 {
8980 127609 return getInput(btnDown, true);
8981 }
8982 127557 bool rLeft()
8983 {
8984 127557 return getInput(btnLeft, true);
8985 }
8986 127093 bool rRight()
8987 {
8988 127093 return getInput(btnRight, true);
8989 }
8990 2987 bool rAbtn()
8991 {
8992 2987 return getInput(btnA, true);
8993 }
8994 128823 bool rBbtn()
8995 {
8996 128823 return getInput(btnB, true);
8997 }
8998 6537665 bool rSbtn()
8999 {
9000 6537665 return getInput(btnS, true);
9001 }
9002 8116376 bool rMbtn()
9003 {
9004 8116376 return getInput(btnM, true);
9005 }
9006 126885 bool rLbtn()
9007 {
9008 126885 return getInput(btnL, true);
9009 }
9010 126880 bool rRbtn()
9011 {
9012 126880 return getInput(btnR, true);
9013 }
9014 6454837 bool rPbtn()
9015 {
9016 6454837 return getInput(btnP, true);
9017 }
9018 bool rEx1btn()
9019 {
9020 return getInput(btnEx1, true);
9021 }
9022 bool rEx2btn()
9023 {
9024 return getInput(btnEx2, true);
9025 }
9026 137531 bool rEx3btn()
9027 {
9028 137531 return getInput(btnEx3, true);
9029 }
9030 137531 bool rEx4btn()
9031 {
9032 137531 return getInput(btnEx4, true);
9033 }
9034 bool rAxisUp()
9035 {
9036 return getInput(btnAxisUp, true);
9037 }
9038 bool rAxisDown()
9039 {
9040 return getInput(btnAxisDown, true);
9041 }
9042 bool rAxisLeft()
9043 {
9044 return getInput(btnAxisLeft, true);
9045 }
9046 bool rAxisRight()
9047 {
9048 return getInput(btnAxisRight, true);
9049 }
9050
9051 bool rF11()
9052 {
9053 return getInput(btnF11, true);
9054 }
9055 bool rQ()
9056 {
9057 return getInput(btnQ, true);
9058 }
9059 bool rI()
9060 {
9061 return getInput(btnI, true);
9062 }
9063
9064 16362288 bool DrunkUp()
9065 {
9066 16362288 return getInput(btnUp, false, true);
9067 }
9068 15236962 bool DrunkDown()
9069 {
9070 15236962 return getInput(btnDown, false, true);
9071 }
9072 9584743 bool DrunkLeft()
9073 {
9074 9584743 return getInput(btnLeft, false, true);
9075 }
9076 8321118 bool DrunkRight()
9077 {
9078 8321118 return getInput(btnRight, false, true);
9079 }
9080 7121460 bool DrunkcAbtn()
9081 {
9082 7121460 return getInput(btnA, false, true);
9083 }
9084 6993513 bool DrunkcBbtn()
9085 {
9086 6993513 return getInput(btnB, false, true);
9087 }
9088 6407809 bool DrunkcEx1btn()
9089 {
9090 6407809 return getInput(btnEx1, false, true);
9091 }
9092 6407829 bool DrunkcEx2btn()
9093 {
9094 6407829 return getInput(btnEx2, false, true);
9095 }
9096 bool DrunkcSbtn()
9097 {
9098 return getInput(btnS, false, true);
9099 }
9100 bool DrunkcMbtn()
9101 {
9102 return getInput(btnM, false, true);
9103 }
9104 bool DrunkcLbtn()
9105 {
9106 return getInput(btnL, false, true);
9107 }
9108 bool DrunkcRbtn()
9109 {
9110 return getInput(btnR, false, true);
9111 }
9112 bool DrunkcPbtn()
9113 {
9114 return getInput(btnP, false, true);
9115 }
9116
9117 bool DrunkrUp()
9118 {
9119 return getInput(btnUp, true, true);
9120 }
9121 bool DrunkrDown()
9122 {
9123 return getInput(btnDown, true, true);
9124 }
9125 bool DrunkrLeft()
9126 {
9127 return getInput(btnLeft, true, true);
9128 }
9129 bool DrunkrRight()
9130 {
9131 return getInput(btnRight, true, true);
9132 }
9133 5366242 bool DrunkrAbtn()
9134 {
9135 5366242 return getInput(btnA, true, true);
9136 }
9137 5381849 bool DrunkrBbtn()
9138 {
9139 5381849 return getInput(btnB, true, true);
9140 }
9141 71669 bool DrunkrEx1btn()
9142 {
9143 71669 return getInput(btnEx1, true, true);
9144 }
9145 71662 bool DrunkrEx2btn()
9146 {
9147 71662 return getInput(btnEx2, true, true);
9148 }
9149 bool DrunkrEx3btn()
9150 {
9151 return getInput(btnEx3, true, true);
9152 }
9153 bool DrunkrEx4btn()
9154 {
9155 return getInput(btnEx4, true, true);
9156 }
9157 bool DrunkrSbtn()
9158 {
9159 return getInput(btnS, true, true);
9160 }
9161 bool DrunkrMbtn()
9162 {
9163 return getInput(btnM, true, true);
9164 }
9165 6037241 bool DrunkrLbtn()
9166 {
9167 6037241 return getInput(btnL, true, true);
9168 }
9169 6033859 bool DrunkrRbtn()
9170 {
9171 6033859 return getInput(btnR, true, true);
9172 }
9173 bool DrunkrPbtn()
9174 {
9175 return getInput(btnP, true, true);
9176 }
9177
9178 8492 void eat_buttons()
9179 {
9180 8492 getInput(btnA, true, false, true);
9181 8492 getInput(btnB, true, false, true);
9182 8492 getInput(btnS, true, false, true);
9183 8492 getInput(btnM, true, false, true);
9184 8492 getInput(btnL, true, false, true);
9185 8492 getInput(btnR, true, false, true);
9186 8492 getInput(btnP, true, false, true);
9187 8492 getInput(btnEx1, true, false, true);
9188 8492 getInput(btnEx2, true, false, true);
9189 8492 getInput(btnEx3, true, false, true);
9190 8492 getInput(btnEx4, true, false, true);
9191 8492 }
9192
9193 // Is true for the _first frame_ of a key press.
9194 // But! it is possible that a script manually sets the value of KeyPress,
9195 // in which case it will be restored to the "true" value based on `key_current_frame`
9196 // and `key_previous_frame` on the next frame.
9197 13 bool zc_readkey(int32_t k, bool ignoreDisable)
9198 {
9199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(ignoreDisable) return KeyPress[k];
9200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 switch(k)
9201 {
9202 case KEY_F7:
9203 case KEY_F8:
9204 case KEY_F9:
9205 return KeyPress[k];
9206
9207 default:
9208
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 return KeyPress[k] && !disabledKeys[k];
9209 }
9210 13 }
9211
9212 // Is true for _every frame_ a key is held down.
9213 // But! it is possible that a script manually sets the value of KeyInput,
9214 // in which case it will be restored to the "true" value based on `key_current_frame`
9215 // on the next frame.
9216 bool zc_getkey(int32_t k, bool ignoreDisable)
9217 {
9218 if(ignoreDisable) return KeyInput[k];
9219 switch(k)
9220 {
9221 case KEY_F7:
9222 case KEY_F8:
9223 case KEY_F9:
9224 return KeyInput[k];
9225
9226 default:
9227 return KeyInput[k] && !disabledKeys[k];
9228 }
9229 }
9230
9231 // Reads (and then clears) the current frame key state directly.
9232 // Scripts can also modify `key_current_frame`.
9233 198 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9234 {
9235
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 196 times.
198 if(zc_getrawkey(k, ignoreDisable))
9236 {
9237 2 _key[k]=key[k]=key_current_frame[k]=0;
9238 2 return true;
9239 }
9240 196 _key[k]=key[k]=key_current_frame[k]=0;
9241 196 return false;
9242 198 }
9243
9244 // Reads the current frame key state directly.
9245 // Scripts can also modify `key_current_frame`.
9246 55151515 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9247 {
9248
2/2
✓ Branch 0 taken 47035113 times.
✓ Branch 1 taken 8116402 times.
55151515 if(ignoreDisable) return key_current_frame[k];
9249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116402 times.
8116402 switch(k)
9250 {
9251 case KEY_F7:
9252 case KEY_F8:
9253 case KEY_F9:
9254 return key_current_frame[k];
9255
9256 default:
9257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116402 times.
8116402 return key_current_frame[k] && !disabledKeys[k];
9258 }
9259 55151515 }
9260
9261 // Only used for a handful of keys, like tilde and Function keys.
9262 // This state is never read within the game.
9263 // It exists so that all keyboard input still functions during replay,
9264 // without inadvertently doing things like toggling throttling if the player
9265 // presses ~
9266 16232848 bool zc_get_system_key(int32_t k)
9267 {
9268 16232848 return key_system[k];
9269 }
9270
9271 // True for the _first_ frame of a key press.
9272 73047384 bool zc_read_system_key(int32_t k)
9273 {
9274 73047384 return key_system_press[k];
9275 }
9276
9277 1030779752 bool is_system_key(int32_t k)
9278 {
9279
2/2
✓ Branch 0 taken 957732368 times.
✓ Branch 1 taken 73047384 times.
1030779752 switch (k)
9280 {
9281 case KEY_BACKQUOTE:
9282 case KEY_CLOSEBRACE:
9283 case KEY_END:
9284 case KEY_HOME:
9285 case KEY_OPENBRACE:
9286 case KEY_PGDN:
9287 case KEY_PGUP:
9288 case KEY_TAB:
9289 case KEY_TILDE:
9290 73047384 return true;
9291 }
9292 957732368 return is_Fkey(k);
9293 1030779752 }
9294
9295 8116376 void update_system_keys()
9296 {
9297
2/2
✓ Branch 0 taken 1030779752 times.
✓ Branch 1 taken 8116376 times.
1038896128 for (int32_t q = 0; q < 127; ++q)
9298 {
9299
2/2
✓ Branch 0 taken 170443896 times.
✓ Branch 1 taken 860335856 times.
1030779752 if (!is_system_key(q))
9300 860335856 continue;
9301
9302 170443896 key_system[q] = key[q];
9303
1/2
✓ Branch 0 taken 170443896 times.
✗ Branch 1 not taken.
170443896 key_system_press[q] = key_system[q] && !key_system_previous[q];
9304 170443896 key_system_previous[q] = key_system[q];
9305 170443896 }
9306 8116376 }
9307
9308 9220666 void update_keys()
9309 {
9310
2/2
✓ Branch 0 taken 1171024582 times.
✓ Branch 1 taken 9220666 times.
1180245248 for (int32_t q = 0; q < 127; ++q)
9311 {
9312 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9313
1/2
✓ Branch 0 taken 1171024582 times.
✗ Branch 1 not taken.
1171024582 if (!replay_is_replaying())
9314 key_current_frame[q] = key[q];
9315
9316
2/2
✓ Branch 0 taken 1162378090 times.
✓ Branch 1 taken 8646492 times.
1171024582 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9317 1171024582 KeyInput[q] = key_current_frame[q];
9318 1171024582 key_previous_frame[q] = key_current_frame[q];
9319 1171024582 }
9320 9220666 }
9321
9322 bool zc_disablekey(int32_t k, bool val)
9323 {
9324 switch(k)
9325 {
9326 case KEY_F7:
9327 case KEY_F8:
9328 case KEY_F9:
9329 return false;
9330
9331 default:
9332 disabledKeys[k] = val;
9333 return true;
9334 }
9335 }
9336
9337 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9338 {
9339 timer=timer;
9340 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9341 }
9342